Geo functions

更新时间:
复制 MD 格式

This topic describes the basic syntax of geo functions and provides examples.

Log Service supports the following geo functions.

Important If you want to use strings in analytic statements, you must enclose strings in single quotation marks (''). Strings that are not enclosed or enclosed in double quotation marks ("") indicate field names or column names. For example, 'status' indicates the status string, and status or "status" indicates the status log field.

Function

Syntax

Description

Supported in SQL

Supported in SPL

geohash function

geohash(x)

Encodes latitude and longitude coordinates into a geohash string.

Note

Log Service converts an IP address into geographic information, such as the country, province, city, ISP, latitude, and longitude. For more information, see IP functions.

×

Geohash function

The geohash function encodes latitude and longitude coordinates into a geohash string.

Syntax

geohash(x)

Parameters

Parameter

Description

x

The geographical coordinate to be encoded. This value is typically the output of another function. For example, the output of: ip_to_geo(client_ip).

Return value type

string

Examples

Use the ip_to_geo function to convert the value of the client_ip field into coordinates, and then use the geohash function to encode the coordinates.

  • Query statement

    * | SELECT geohash(ip_to_geo(client_ip)) AS hash
  • In the query results, the hash column returns wwgqdmdu2v96.