Hive: Map geometry and geography type to binary in HiveSchemaUtil#17112
Open
csringhofer wants to merge 1 commit into
Open
Hive: Map geometry and geography type to binary in HiveSchemaUtil#17112csringhofer wants to merge 1 commit into
csringhofer wants to merge 1 commit into
Conversation
| public void testGeometryTypeConvertToHiveSchema() { | ||
| Schema schema = new Schema(optional(0, "geometry_field", Types.GeometryType.crs84())); | ||
| List<FieldSchema> hiveSchema = HiveSchemaUtil.convert(schema); | ||
| assertThat(hiveSchema).containsExactly(new FieldSchema("geometry_field", "binary", null)); |
Contributor
There was a problem hiding this comment.
add a .describedAs("hive schema %s", schema) before the .containsExactly() for even better assertion details.
| return "timestamp"; | ||
| case FIXED: | ||
| case BINARY: | ||
| case GEOMETRY: |
Contributor
There was a problem hiding this comment.
as noted by the automated review, consider moving this switch statement to the java17
case key -> value style. The codebase moved to it entirely last month, then moved back to ease cherrypicking; if you look at the file history you can find the diff so see what to bring over, just for this switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add GEOMETRY and GEOGRAPHY cases to HiveSchemaUtil.convertToTypeString, mapping them to "binary".
"binary" was chosen instead of "unknown" because geometry/geography are WKB-encoded byte arrays - older readers not familiar with Iceberg/Parquet GEOMETRY can still read the created Parquet files by reading the column as BINARY and converting from WKB to their representation (st_GeomFromWKB() in Hive).
Motivation:
Bumped into this while integrating Iceberg geometry support into Apache Impala, which uses the Hive catalog for tests. Creating a table with a geometry column would throw UnsupportedOperationException from the default
branch of the switch. By patching HiveSchemaUtil in Iceberg I as able to create tables with GEOMETRY columns.