[
https://issues.apache.org/jira/browse/HIVE-30240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dmitriy Fingerman updated HIVE-30240:
-------------------------------------
Description:
Iceberg format version 3 defines a GEOMETRY type: an ISO WKB value with an
optional coordinate
reference system (CRS). Hive currently can't create, read or write such
columns. This ticket adds
GEOMETRY as a Hive data type for Iceberg v3 tables.
h3. Example
{code:sql}
CREATE TABLE places (
id INT,
geom GEOMETRY, -- default CRS: OGC:CRS84
geom2 GEOMETRY('EPSG:3857') -- explicit CRS
) STORED BY ICEBERG TBLPROPERTIES ('format-version'='3');
INSERT INTO places VALUES
(1, unhex('0101000000000000000000F03F0000000000000040'), NULL),
(2, CAST(ST_AsBinary(ST_GeomFromText('POINT (3 4)')) AS GEOMETRY), NULL);
SELECT id, ST_AsText(ST_GeomFromWKB(CAST(geom AS BINARY))) FROM places;
{code}
h3. Scope
* *Type system:* a new primitive type whose CRS is part of the type: geometry
or geometry('EPSG:3857'). Values are ISO WKB bytes.
* *Parser and compiler:*
** GEOMETRY and GEOMETRY('crs') in DDL. GEOMETRY is a non-reserved keyword, so
existing columns named "geometry" keep working.
** Calcite type mapping, plus CAST to and from BINARY.
** Implicit BINARY to GEOMETRY conversion on INSERT.
* *Iceberg:*
** Mapping to and from Iceberg's GeometryType, keeping the CRS.
** Row-mode and vectorized read/write, including the Parquet vectorized reader.
** Nested use in struct, array and map.
* *HiveServer2/JDBC:* new TTypeId GEOMETRY_TYPE and Thrift protocol version V13.
** Values are returned as raw WKB, reported as java.sql.Types.BINARY with type
name "geometry".
** Older clients are unaffected.
h3. Semantics and restrictions
* *CRS is a label only:* Hive never reprojects coordinates.
** OGC:CRS84 is the default, and any spelling of it is normalized to OGC:CRS84.
** Other CRS strings are stored as written. Compatibility checks in CAST,
INSERT and UNION ignore case.
* *CRS mismatches fail:*
** CAST, INSERT and UNION/CASE/COALESCE between different CRSs raise an error.
** To relabel deliberately, cast through BINARY: CAST(CAST(g AS BINARY) AS
GEOMETRY('EPSG:3857')).
* *WKB validation:* values are structurally validated on conversion. Accepted:
ISO WKB in either byte order, with Z, M or ZM, including GEOMETRYCOLLECTION.
Rejected: malformed WKB and PostGIS EWKB.
* *No implicit string conversion:* STRING to GEOMETRY is rejected, to avoid
storing text bytes as WKB. Parse text explicitly with ST_GeomFromText +
ST_AsBinary.
* *Iceberg v3 only:* GEOMETRY is rejected on non-Iceberg tables.
* *Parquet only:* Iceberg can't write geometry to ORC, so CREATE/ALTER with an
ORC write format is rejected up front. Previously this failed inside the task
at write time.
* *Not allowed* (Iceberg can't support these):
** partition columns and partition transforms (identity, bucket);
** WRITE LOCALLY ORDERED BY keys;
** column default values;
** changing a column's type between GEOMETRY and BINARY, or between CRSs.
h3. Also included
ReExecuteOnWriteConflictPlugin kept its retry flag in a static field, so one
failed query could make an unrelated later query re-execute. That showed up as
duplicated output in the Iceberg negative q-files. The flag is now per instance
and is reset before each execution.
h3. Out of scope (follow-ups)
* GEOGRAPHY type.
* Native GEOMETRY support in Hive's ESRI ST_* functions. For now, bridge with
ST_GeomFromWKB(CAST(g AS BINARY)) and CAST(ST_AsBinary(...) AS GEOMETRY).
* Spatial predicate pushdown. This is blocked until Iceberg exposes spatial
predicates; Iceberg already writes geometry bounds on Hive writes.
h3. Testing
* *Unit tests:* TestGeometryTypeInfo, TestWkbValidator,
TestGenericUDFToGeometry, TestFunctionRegistry, TestHiveSchemaUtil,
TestIcebergObjectInspector, TestIcebergBinaryObjectInspector, TestColumnBuffer,
TestReExecuteOnWriteConflictPlugin.
* *Iceberg end-to-end:* TestHiveIcebergGeometryType.
* *JDBC:* TestJdbcDriver2#testGeometryType (result-set metadata, values, NULLs
and getColumns).
* *Iceberg positive q-files:* geometry_type, geometry_type_dml,
geometry_type_expressions, geometry_type_nested, geometry_type_vectorization.
* *Iceberg negative q-files:* 16, covering ORC, CRS mismatches, EWKB/invalid
WKB, string input, partitioning, sort order, default values and type changes.
* *ql negative q-files:* 5, covering a non-Iceberg table, a partition column,
string and invalid-WKB casts, and a CRS cast.
> Iceberg: Add basic support for GEOMETRY data type
> -------------------------------------------------
>
> Key: HIVE-30240
> URL: https://issues.apache.org/jira/browse/HIVE-30240
> Project: Hive
> Issue Type: New Feature
> Components: Hive, Iceberg integration
> Reporter: Dmitriy Fingerman
> Assignee: Dmitriy Fingerman
> Priority: Major
> Labels: pull-request-available
>
> Iceberg format version 3 defines a GEOMETRY type: an ISO WKB value with an
> optional coordinate
> reference system (CRS). Hive currently can't create, read or write such
> columns. This ticket adds
> GEOMETRY as a Hive data type for Iceberg v3 tables.
> h3. Example
> {code:sql}
> CREATE TABLE places (
> id INT,
> geom GEOMETRY, -- default CRS: OGC:CRS84
> geom2 GEOMETRY('EPSG:3857') -- explicit CRS
> ) STORED BY ICEBERG TBLPROPERTIES ('format-version'='3');
> INSERT INTO places VALUES
> (1, unhex('0101000000000000000000F03F0000000000000040'), NULL),
> (2, CAST(ST_AsBinary(ST_GeomFromText('POINT (3 4)')) AS GEOMETRY), NULL);
> SELECT id, ST_AsText(ST_GeomFromWKB(CAST(geom AS BINARY))) FROM places;
> {code}
> h3. Scope
> * *Type system:* a new primitive type whose CRS is part of the type: geometry
> or geometry('EPSG:3857'). Values are ISO WKB bytes.
> * *Parser and compiler:*
> ** GEOMETRY and GEOMETRY('crs') in DDL. GEOMETRY is a non-reserved keyword,
> so existing columns named "geometry" keep working.
> ** Calcite type mapping, plus CAST to and from BINARY.
> ** Implicit BINARY to GEOMETRY conversion on INSERT.
> * *Iceberg:*
> ** Mapping to and from Iceberg's GeometryType, keeping the CRS.
> ** Row-mode and vectorized read/write, including the Parquet vectorized
> reader.
> ** Nested use in struct, array and map.
> * *HiveServer2/JDBC:* new TTypeId GEOMETRY_TYPE and Thrift protocol version
> V13.
> ** Values are returned as raw WKB, reported as java.sql.Types.BINARY with
> type name "geometry".
> ** Older clients are unaffected.
> h3. Semantics and restrictions
> * *CRS is a label only:* Hive never reprojects coordinates.
> ** OGC:CRS84 is the default, and any spelling of it is normalized to
> OGC:CRS84.
> ** Other CRS strings are stored as written. Compatibility checks in CAST,
> INSERT and UNION ignore case.
> * *CRS mismatches fail:*
> ** CAST, INSERT and UNION/CASE/COALESCE between different CRSs raise an error.
> ** To relabel deliberately, cast through BINARY: CAST(CAST(g AS BINARY) AS
> GEOMETRY('EPSG:3857')).
> * *WKB validation:* values are structurally validated on conversion.
> Accepted: ISO WKB in either byte order, with Z, M or ZM, including
> GEOMETRYCOLLECTION. Rejected: malformed WKB and PostGIS EWKB.
> * *No implicit string conversion:* STRING to GEOMETRY is rejected, to avoid
> storing text bytes as WKB. Parse text explicitly with ST_GeomFromText +
> ST_AsBinary.
> * *Iceberg v3 only:* GEOMETRY is rejected on non-Iceberg tables.
> * *Parquet only:* Iceberg can't write geometry to ORC, so CREATE/ALTER with
> an ORC write format is rejected up front. Previously this failed inside the
> task at write time.
> * *Not allowed* (Iceberg can't support these):
> ** partition columns and partition transforms (identity, bucket);
> ** WRITE LOCALLY ORDERED BY keys;
> ** column default values;
> ** changing a column's type between GEOMETRY and BINARY, or between CRSs.
> h3. Also included
> ReExecuteOnWriteConflictPlugin kept its retry flag in a static field, so one
> failed query could make an unrelated later query re-execute. That showed up
> as duplicated output in the Iceberg negative q-files. The flag is now per
> instance and is reset before each execution.
> h3. Out of scope (follow-ups)
> * GEOGRAPHY type.
> * Native GEOMETRY support in Hive's ESRI ST_* functions. For now, bridge with
> ST_GeomFromWKB(CAST(g AS BINARY)) and CAST(ST_AsBinary(...) AS GEOMETRY).
> * Spatial predicate pushdown. This is blocked until Iceberg exposes spatial
> predicates; Iceberg already writes geometry bounds on Hive writes.
> h3. Testing
> * *Unit tests:* TestGeometryTypeInfo, TestWkbValidator,
> TestGenericUDFToGeometry, TestFunctionRegistry, TestHiveSchemaUtil,
> TestIcebergObjectInspector, TestIcebergBinaryObjectInspector,
> TestColumnBuffer, TestReExecuteOnWriteConflictPlugin.
> * *Iceberg end-to-end:* TestHiveIcebergGeometryType.
> * *JDBC:* TestJdbcDriver2#testGeometryType (result-set metadata, values,
> NULLs and getColumns).
> * *Iceberg positive q-files:* geometry_type, geometry_type_dml,
> geometry_type_expressions, geometry_type_nested, geometry_type_vectorization.
> * *Iceberg negative q-files:* 16, covering ORC, CRS mismatches, EWKB/invalid
> WKB, string input, partitioning, sort order, default values and type changes.
> * *ql negative q-files:* 5, covering a non-Iceberg table, a partition column,
> string and invalid-WKB casts, and a CRS cast.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)