mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-21 23:40:38 +00:00
* feat: list/array support for postgres output * fix: implement time zone support for postgrsql * feat: add a geohash function that returns array * fix: typo * fix: lint warnings * test: add sqlness test * refactor: check resolution range before convert value * fix: test result for sqlness * feat: upgrade pgwire apis
239 lines
18 KiB
Plaintext
239 lines
18 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] |
|
|
+----------------------------------------------------------------------------------------------------------+
|
|
|