h3_boundaryaswkb function (Databricks SQL)

Returns the polygonal boundary of the input H3 cell in WKB format.

Requires: SQL warehouse version 2022.35 or higher. This version is available in the Preview channel.

Syntax

h3_boundaryaswkb ( h3CellIdExpr )

Arguments

  • h3CellIdExpr: A BIGINT expression, or a hexadecimal STRING expression representing an H3 cell ID.

Returns

A value of the type BINARY representing the polygonal boundary of the input H3 cell in WKB format.

The function returns NULL if the input expression is NULL. The function does partial validation regarding whether the input argument is a valid H3 cell ID. A necessary, but not sufficient condition for a valid H3 ID is that its value is between 0x08001fffffffffff and 0x08ff3b6db6db6db6. The behavior of the function is undefined if the input cell ID is not a valid cell ID.

Error conditions

  • If h3CellIdExpr is a STRING that cannot be converted to a BIGINT or corresponds to a BIGINT value that is smaller than 0x08001fffffffffff or larger than 0x08ff3b6db6db6db6, the function returns H3_INVALID_CELL_ID.

Examples

-- Input a BIGINT representing a hexagonal cell.
> SELECT hex(h3_boundaryaswkb(599686042433355775))
  01030000000100000007000000E27B13AD907A5EC08998FEC9BBA24240300C97AA2E775EC0A2CC41764DAD4240159571711B7B5EC0DCE64CE2D3B64240255DE93F6A825EC08F5EC9C6C6B54240B4356B96C9855EC0546EAB0935AB42407ACFBCCBDC815EC0CBADA278B0A14240E27B13AD907A5EC08998FEC9BBA24240

-- Input a STRING representing a pentagonal cell.
> SELECT hex(h3_boundaryaswkb('8009fffffffffff'))
  01030000000100000006000000418DC418D4E324C0212965BB2A8C4F40DA750FCD3618164003D6996377DA4B4022DC574A2D153940770583D265334D4098617DCCCED43F40BE65106E843B5140677635CDCCD6D43F4DDB71B4DA535240418DC418D4E324C0212965BB2A8C4F40

-- Input is an invalid H3 cell ID.
> SELECT h3_boundaryaswkb(0)
  [H3_INVALID_CELL_ID] 0 is not a valid H3 cell ID