-
Notifications
You must be signed in to change notification settings - Fork 1.5k
PARQUET-2417: Add geometry and geography logical type annotations
#3200
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
Merged
wgtmac
merged 10 commits into
apache:master
from
zhangfengcdt:feature-add-geo-logical-types
Apr 29, 2025
+571
−0
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9344ae9
PARQUET-2417: Add geo logical type annotations to parquet-java
zhangfengcdt a65945b
add types
zhangfengcdt 1022778
converter
zhangfengcdt 742a511
fix to string
zhangfengcdt 1e9f1f3
fix fmt
zhangfengcdt 1f0f986
fix dependency issue
zhangfengcdt 0eee71b
address pr review comments
zhangfengcdt e3b9dbb
add unit tests to TestParquetMetadataConverter
zhangfengcdt 3304de6
address review comments and refactor the algorithm conversion
zhangfengcdt 89d8a74
fix and refactor metadata converter
wgtmac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
64 changes: 64 additions & 0 deletions
64
...uet-column/src/main/java/org/apache/parquet/column/schema/EdgeInterpolationAlgorithm.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.parquet.column.schema; | ||
|
|
||
| /** | ||
| * Edge interpolation algorithm for Geography logical type | ||
| */ | ||
| public enum EdgeInterpolationAlgorithm { | ||
| SPHERICAL(0), | ||
| VINCENTY(1), | ||
| THOMAS(2), | ||
| ANDOYER(3), | ||
| KARNEY(4); | ||
|
|
||
| private final int value; | ||
|
|
||
| private EdgeInterpolationAlgorithm(int value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| /** | ||
| * Get the integer value of this enum value, as defined in the Thrift IDL. | ||
| */ | ||
| public int getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| /** | ||
| * Find the enum type by its integer value, as defined in the Thrift IDL. | ||
| * @return null if the value is not found. | ||
| */ | ||
| public static EdgeInterpolationAlgorithm findByValue(int value) { | ||
| switch (value) { | ||
| case 0: | ||
| return SPHERICAL; | ||
| case 1: | ||
| return VINCENTY; | ||
| case 2: | ||
| return THOMAS; | ||
| case 3: | ||
| return ANDOYER; | ||
| case 4: | ||
| return KARNEY; | ||
| default: | ||
| throw new IllegalArgumentException("Unrecognized EdgeInterpolationAlgorithm value: " + value); | ||
| } | ||
| } | ||
| } |
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
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
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
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
Oops, something went wrong.
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.
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.
@wgtmac and @zhangfengcdt, what do you think about updating this to use WKT only if JTS is available, rather than adding JTS to the classpath for all downstream clients? This could just produce a generic string if a geo library isn't available.
Uh oh!
There was an error while loading. Please reload this page.
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.
It makes sense for the printer. To implement geospatial statistics, we need to depend on JTS to parse WKB. Otherwise we could only blindly write them as blobs without producing any bbox and other stats. If this is acceptable, I think we can make such changes.
@jiayuasu @szehon-ho WDYT?
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.
I believe it’s reasonable to add JTS as a dependency. Its license is compatible with the ASF, and it’s the most widely used geospatial library in the industry. The API is also very stable. JTS has been around for over 20 years.
An alternative would be to implement a standalone WKB parser and maintain it within
parquet-java, but that could introduce significant long-term maintenance overhead for the community.For context, the Parquet Geo C++ PR included a standalone WKB parser because (1) there isn’t a clean, well-maintained WKB parser in C++, and (2) Dewey had already implemented WKB parsing in C++ multiple times before.