Skip to main content

Module iceberg_hash

Module iceberg_hash 

Source
Expand description

SQL forms of the hash used by iceberg_hash partition rules.

iceberg_hash(col) is the same function partition rules evaluate, exposed so that users can measure a distribution or verify which bucket a value falls into. It must never diverge from the rule form: both are built from partition::function::iceberg_hash_udf.

iceberg_hash_bounds(n) prints the breakpoints of an equal-width n-bucket split, ready to paste into PARTITION ON COLUMNS. It only formats the numbers; it does not create or change partitions.

iceberg_hash_breakpoints(v1, v2, ...) hashes the given constant values (any order, all from one hash encoding: strings, or integers) and prints them sorted, for building buckets around known key values instead of around equal widths.

iceberg_hash_ranges_sql(column, n) renders the whole rule list for PARTITION ON COLUMNS from an equal-width split, so it can be pasted without expanding the breakpoints by hand. The column name is quoted, so names that are not plain lowercase identifiers round-trip.

Structsยง

IcebergHashBoundsFunction ๐Ÿ”’
iceberg_hash_bounds(n): the n - 1 equal-width breakpoints of the hash space, as comma separated INT32 literals.
IcebergHashBreakpointsFunction ๐Ÿ”’
iceberg_hash_breakpoints(v1, v2, ...): the sorted, comma separated hash values of the given constant values, as INT32 literals.
IcebergHashFunction ๐Ÿ”’
iceberg_hash(col): registers the UDF partition rules already plan.
IcebergHashRangesSqlFunction ๐Ÿ”’
iceberg_hash_ranges_sql(column, n): the ready-to-paste rule list for PARTITION ON COLUMNS, built from an equal-width n-bucket split.

Enumsยง

HashDomain ๐Ÿ”’
The hash encoding a constant goes through. Integer widths share one encoding (INT32, UINT8, โ€ฆ all hash as Iceberg longs), while strings use their UTF-8 bytes, so mixing the two produces breakpoints that do not describe a single column.

Constantsยง

MAX_BUCKETS ๐Ÿ”’
iceberg_hash_bounds hard limit. Each region carries its own WAL, memtable, manifest and compaction stream, so four-digit bucket counts are already far beyond any practical table.

Functionsยง

equal_split_breakpoints ๐Ÿ”’
Returns the n - 1 equal-width breakpoints of buckets over INT32, following bi = i32::MIN + floor(i * 2^32 / n).
into_hashed_scalar ๐Ÿ”’
Hashes one constant by evaluating it through the shared array form, so the value goes through exactly the code a partition rule evaluates.
quoted_identifier ๐Ÿ”’
Quotes a column name as a SQL identifier: wrap it in double quotes and double every embedded quote.