mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-07 22:02:56 +00:00
* feat: add geojson function to aggregate paths * test: add sqlness results * test: add sqlness * refactor: corrected to aggregation function * chore: update comments * fix: make linter happy again * refactor: rename to remove `geo` from `geojson` function name The return type is not geojson at all. It's just compatible with geojson's coordinates part and superset's deckgl path plugin.
264 lines
20 KiB
Plaintext
264 lines
20 KiB
Plaintext
SELECT h3_latlng_to_cell(37.76938, -122.3889, 0), h3_latlng_to_cell_string(37.76938, -122.3889, 0);;
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),Int64(0)) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),Int64(0)) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| 577199624117288959 | 8029fffffffffff |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 1), h3_latlng_to_cell_string(37.76938, -122.3889, 1);
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),Int64(1)) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),Int64(1)) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| 581672437419081727 | 81283ffffffffff |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8), h3_latlng_to_cell_string(37.76938, -122.3889, 8);
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),Int64(8)) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),Int64(8)) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 100), h3_latlng_to_cell_string(37.76938, -122.3889, 100);
|
|
|
|
Error: 3001(EngineExecuteQuery), H3 error: invalid resolution (got Some(100)): out of range
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, -1), h3_latlng_to_cell_string(37.76938, -122.3889, -1);
|
|
|
|
Error: 3001(EngineExecuteQuery), H3 error: invalid resolution (got Some(255)): out of range
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::Int8), h3_latlng_to_cell_string(37.76938, -122.3889, 8::Int8);
|
|
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),Int64(8)) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),Int64(8)) |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+------------------------------------------------------------------+-------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::Int16), h3_latlng_to_cell_string(37.76938, -122.3889, 8::Int16);
|
|
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int16"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int16"))) |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::Int32), h3_latlng_to_cell_string(37.76938, -122.3889, 8::Int32);
|
|
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int32"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int32"))) |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::Int64), h3_latlng_to_cell_string(37.76938, -122.3889, 8::Int64);
|
|
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int64"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("Int64"))) |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt8), h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt8);
|
|
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt8"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt8"))) |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt16), h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt8);
|
|
|
|
+---------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt16"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt8"))) |
|
|
+---------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+---------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt32), h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt32);
|
|
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt32"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt32"))) |
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64), h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt64);
|
|
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
| h3_latlng_to_cell(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt64"))) | h3_latlng_to_cell_string(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(8),Utf8("UInt64"))) |
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
| 613196570438926335 | 88283082e7fffff |
|
|
+---------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT h3_cell_to_string(h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64)) AS cell_str, h3_string_to_cell(h3_latlng_to_cell_string(37.76938, -122.3889, 8::UInt64)) AS cell_index;
|
|
|
|
+-----------------+--------------------+
|
|
| cell_str | cell_index |
|
|
+-----------------+--------------------+
|
|
| 88283082e7fffff | 613196570438926335 |
|
|
+-----------------+--------------------+
|
|
|
|
SELECT h3_cell_center_lat(h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64)) AS cell_center_lat, h3_cell_center_lng(h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64)) AS cell_center_lng;
|
|
|
|
+-------------------+---------------------+
|
|
| cell_center_lat | cell_center_lng |
|
|
+-------------------+---------------------+
|
|
| 37.77246152245501 | -122.39010997087324 |
|
|
+-------------------+---------------------+
|
|
|
|
SELECT
|
|
h3_cell_resolution(cell) AS resolution,
|
|
h3_cell_base(cell) AS base,
|
|
h3_cell_is_pentagon(cell) AS pentagon,
|
|
h3_cell_parent(cell, 6::UInt64) AS parent,
|
|
FROM (SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64) AS cell);
|
|
|
|
+------------+------+----------+--------------------+
|
|
| resolution | base | pentagon | parent |
|
|
+------------+------+----------+--------------------+
|
|
| 8 | 20 | false | 604189371209351167 |
|
|
+------------+------+----------+--------------------+
|
|
|
|
SELECT h3_is_neighbour(cell1, cell2)
|
|
FROM (SELECT h3_latlng_to_cell(37.76938, -122.3889, 8::UInt64) AS cell1, h3_latlng_to_cell(36.76938, -122.3889, 8::UInt64) AS cell2);
|
|
|
|
+------------------------------+
|
|
| h3_is_neighbour(cell1,cell2) |
|
|
+------------------------------+
|
|
| false |
|
|
+------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 9);
|
|
|
|
+--------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),Int64(9)) |
|
|
+--------------------------------------------------------+
|
|
| 9q8yygxne |
|
|
+--------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 10);
|
|
|
|
+---------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),Int64(10)) |
|
|
+---------------------------------------------------------+
|
|
| 9q8yygxnef |
|
|
+---------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11);
|
|
|
|
+---------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),Int64(11)) |
|
|
+---------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+---------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 100);
|
|
|
|
Error: 3001(EngineExecuteQuery), Invalid geohash resolution 100, expect value: [1, 12]
|
|
|
|
SELECT geohash(37.76938, -122.3889, -1);
|
|
|
|
Error: 3001(EngineExecuteQuery), Invalid geohash resolution -1, expect value: [1, 12]
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::Int8);
|
|
|
|
+---------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),Int64(11)) |
|
|
+---------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+---------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::Int16);
|
|
|
|
+-----------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("Int16"))) |
|
|
+-----------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+-----------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::Int32);
|
|
|
|
+-----------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("Int32"))) |
|
|
+-----------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+-----------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::Int64);
|
|
|
|
+-----------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("Int64"))) |
|
|
+-----------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+-----------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::UInt8);
|
|
|
|
+-----------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("UInt8"))) |
|
|
+-----------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+-----------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::UInt16);
|
|
|
|
+------------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("UInt16"))) |
|
|
+------------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+------------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::UInt32);
|
|
|
|
+------------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("UInt32"))) |
|
|
+------------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+------------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash(37.76938, -122.3889, 11::UInt64);
|
|
|
|
+------------------------------------------------------------------------------------+
|
|
| geohash(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(11),Utf8("UInt64"))) |
|
|
+------------------------------------------------------------------------------------+
|
|
| 9q8yygxneft |
|
|
+------------------------------------------------------------------------------------+
|
|
|
|
SELECT geohash_neighbours(37.76938, -122.3889, 11);
|
|
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| geohash_neighbours(Float64(37.76938),Float64(-122.3889),Int64(11)) |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
| [9q8yygxnefv, 9q8yygxnefu, 9q8yygxnefs, 9q8yygxnefk, 9q8yygxnefm, 9q8yygxnefq, 9q8yygxnefw, 9q8yygxnefy] |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT json_encode_path(37.76938, -122.3889, 1728083375::TimestampSecond);
|
|
|
|
+----------------------------------------------------------------------------------------------------------------------+
|
|
| json_encode_path(Float64(37.76938),Float64(-122.3889),arrow_cast(Int64(1728083375),Utf8("Timestamp(Second, None)"))) |
|
|
+----------------------------------------------------------------------------------------------------------------------+
|
|
| [[-122.3889,37.76938]] |
|
|
+----------------------------------------------------------------------------------------------------------------------+
|
|
|
|
SELECT json_encode_path(lat, lon, ts)
|
|
FROM(
|
|
SELECT 37.76938 AS lat, -122.3889 AS lon, 1728083375::TimestampSecond AS ts
|
|
UNION ALL
|
|
SELECT 37.76928 AS lat, -122.3839 AS lon, 1728083373::TimestampSecond AS ts
|
|
UNION ALL
|
|
SELECT 37.76930 AS lat, -122.3820 AS lon, 1728083379::TimestampSecond AS ts
|
|
UNION ALL
|
|
SELECT 37.77001 AS lat, -122.3888 AS lon, 1728083372::TimestampSecond AS ts
|
|
);
|
|
|
|
+-------------------------------------------------------------------------------------+
|
|
| json_encode_path(lat,lon,ts) |
|
|
+-------------------------------------------------------------------------------------+
|
|
| [[-122.3888,37.77001],[-122.3839,37.76928],[-122.3889,37.76938],[-122.382,37.7693]] |
|
|
+-------------------------------------------------------------------------------------+
|
|
|