-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Parquet: Validate geospatial projection parameters #17578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1360372
a6bc8b5
d1e612f
e86bf5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |
| import org.apache.iceberg.relocated.com.google.common.base.Objects; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Lists; | ||
| import org.apache.iceberg.types.Type.TypeID; | ||
| import org.apache.iceberg.types.TypeUtil; | ||
| import org.apache.iceberg.types.Types.ListType; | ||
| import org.apache.iceberg.types.Types.MapType; | ||
| import org.apache.iceberg.types.Types.NestedField; | ||
|
|
@@ -162,9 +164,22 @@ public Type variant( | |
| @Override | ||
| public Type primitive( | ||
| org.apache.iceberg.types.Type.PrimitiveType expected, PrimitiveType primitive) { | ||
| validatePrimitive(expected, primitive); | ||
| return null; | ||
| } | ||
|
|
||
| static void validatePrimitive( | ||
| org.apache.iceberg.types.Type.PrimitiveType expected, PrimitiveType primitive) { | ||
| if (expected != null | ||
| && (expected.typeId() == TypeID.GEOMETRY || expected.typeId() == TypeID.GEOGRAPHY)) { | ||
| Preconditions.checkArgument( | ||
| TypeUtil.isPromotionAllowed(MessageTypeToType.convertPrimitive(primitive), expected), | ||
| "Cannot read Parquet type %s as Iceberg type %s", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Column name in the error - PruneColumns.java:179: "Cannot read Parquet type %s as Iceberg type %s" omits the column name, so on a wide table the user can't tell which field mismatched. TypeWithSchemaVisitor exposes currentPath() (the fieldNames deque, ~line 254) that primitive() can use to include the path, per AGENTS.md:119 (actionable messages). |
||
| primitive, | ||
| expected); | ||
| } | ||
| } | ||
|
|
||
| private Integer getId(Type type) { | ||
| return type.getId() == null ? null : type.getId().intValue(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested types in the fallback path - ParquetSchemaUtil.java:162-171 (pruneColumnsFallback) validates only top-level primitives: the type.isPrimitive() && expectedField.type().isPrimitiveType() guard skips any top-level struct/list/map that contains a nested geometry/geography field, so CRS/algorithm go unchecked on the id-less path (the id-based PruneColumns visitor reaches nested types fine via recursive descent). Either recurse positionally against the projected type, or add an explicit comment documenting the top-level-only scope.