h3_compact
fungsi
Berlaku untuk: Databricks SQL Databricks Runtime 11.3 LTS ke atas
Memampatkan set input sel H3. Set yang dikompresi mencakup set sel H3 yang sama dengan yang asli.
Sintaks
h3_compact ( h3CellIdsExpr )
Argumen
h3CellIdsExpr
: ARRAY ekspresi BIGINTs, atau ARRAY ekspresi STRING heksadesimal yang mewakili array ID sel H3.
Mengembalikan
ARRAY ID sel H3 dengan jenis yang sama dengan nilai dalam ekspresi h3CellIdsExpr
ARRAY input .
Fungsi mengembalikan NULL jika input adalah NULL.
Fungsi melakukan validasi parsial mengenai apakah argumen input adalah ID sel H3 yang valid. Kondisi yang diperlukan, tetapi tidak memadai untuk ID H3 yang valid adalah bahwa nilainya antara 0x08001fffffffffff
dan 0x08ff3b6db6db6db6
.
Perilaku fungsi tidak terdefinisi jika salah satu ID sel dalam ARRAY input bukan ID sel yang valid.
Nilai NULL dalam array input diabaikan.
Kondisi kesalahan
- Jika
h3CellIdExpr
adalah STRING yang tidak dapat dikonversi ke BIGINT atau sesuai dengan nilai BIGINT yang lebih kecil dari0x08001fffffffffff
atau lebih besar dari0x08ff3b6db6db6db6
, fungsi mengembalikan H3_INVALID_CELL_ID.
Contoh
-- Example where the input is an ARRAY of BIGINTs
> SELECT h3_compact(ARRAY(599686042433355775,599686030622195711,599686044580839423,599686038138388479,599686043507097599,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686040285872127,599686041359613951,599686039212130303,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647));
[599686030622195711,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647,595182446027210751]
-- Example where the input is an ARRAY of hexadecimal STRINGs
> SELECT h3_compact(ARRAY('85283473fffffff', '85283447fffffff', '8528347bfffffff', '85283463fffffff', '85283477fffffff', '8528340ffffffff', '8528340bfffffff', '85283457fffffff', '85283443fffffff', '8528344ffffffff', '852836b7fffffff', '8528346bfffffff', '8528346ffffffff', '85283467fffffff', '8528342bfffffff', '8528343bfffffff', '85283407fffffff', '85283403fffffff', '8528341bfffffff'));
[85283447fffffff, 8528340ffffffff, 8528340bfffffff, 85283457fffffff, 85283443fffffff, 8528344ffffffff, 852836b7fffffff, 8528342bfffffff, 8528343bfffffff, 85283407fffffff, 85283403fffffff, 8528341bfffffff, 8428347ffffffff]
-- Example where the input ARRAY consists of a single element (and thus cannot be compacted further).
> SELECT h3_compact(ARRAY('85283473fffffff'));
[85283473fffffff]
-- Example where we compare the size of the 2-ring of an H3 cell with its compacted version.
> SELECT ARRAY_SIZE(h3_kring(599686042433355775, 2)), ARRAY_SIZE(h3_compact(h3_kring(599686042433355775, 2)))
19 13
-- Example where one of the cell IDs is out of range.
> SELECT h3_compact(ARRAY(599686042433355775, 0))
[H3_INVALID_CELL_ID] 0 is not a valid H3 cell ID