Skip to content

ORC-1920: [C++] Support Geometry and Geography types - #2269

Closed
ffacs wants to merge 16 commits into
apache:mainfrom
ffacs:geo
Closed

ORC-1920: [C++] Support Geometry and Geography types#2269
ffacs wants to merge 16 commits into
apache:mainfrom
ffacs:geo

Conversation

@ffacs

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?
Support Geometry and Geography types for c++ side

Why are the changes needed?
Add support for Geometry and Geography types

How was this patch tested?
UT passed

Was this patch authored or co-authored using generative AI tooling?
No

@ffacsffacs changed the title ORC-1920: Support Geometry and Geography typesORC-1920: [C++] Support Geometry and Geography typesJun 16, 2025
@ffacsffacs changed the title ORC-1920: [C++] Support Geometry and Geography typesORC-1920: [C++] Support Geometry and Geography typesJun 16, 2025

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ffacs .

cc @wgtmac and @williamhyun

@dongjoon-hyundongjoon-hyun added this to the 2.2.0 milestone Jun 16, 2025
Comment threadc++/include/orc/Geospatial.hh
///
/// These values correspond to the 1, 2, ..., 7 component of the WKB integer
/// geometry type (i.e., the value of geometry_type % 1000).
enum class GeometryType {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Java, we had an additional value, -1, for UNKNOWN_TYPE_ID.

privatestaticfinalintUNKNOWN_TYPE_ID = -1;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ employs a different implementation that invalidates statistics when unknown types are encountered; therefore, UNKNOWN_TYPE_ID is unnecessary in this context.

Comment threadc++/src/Geospatial.cc Outdated
Comment threadc++/src/Statistics.hh
}

std::stringstream ss;
ss << "<GeoStatistics>";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. Why do we have this only in C++ implementation? If this is required, can we have this in Java first?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is due to gap between Parquet Java and C++ implementations...

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is due to gap between Parquet Java and C++ implementations..

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few minor comments about the feature parity between Java and C++ implementations.

@williamhyunwilliamhyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thank you @ffacs for this PR, waiting on the above comment before merging.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Gentle ping, @ffacs .

@ffacs

Copy link
Copy Markdown
ContributorAuthor

Gentle ping, @ffacs .

Pong. Thank you for your review @dongjoon-hyun , I'd update this patch these days.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you, @ffacs . Also, please participate the 1.8.10 vote too when you have some time.

Comment threadc++/include/orc/Geospatial.hh Outdated
Comment threadc++/include/orc/Statistics.hh Outdated
Comment threadtools/src/CSVFileImport.cc Outdated
Comment threadc++/src/TypeImpl.cc Outdated
Comment threadc++/src/TypeImpl.cc Outdated
Comment threadc++/src/TypeImpl.cc Outdated
Comment threadc++/src/Statistics.hh
}

std::stringstream ss;
ss << "<GeoStatistics>";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is due to gap between Parquet Java and C++ implementations...

@dongjoon-hyun

Copy link
Copy Markdown
Member

Could you fix the above comments, @ffacs ?

@wgtmac

Copy link
Copy Markdown
Member

Let me know when ready to review.

@ffacs

ffacs commented Jul 3, 2025

Copy link
Copy Markdown
ContributorAuthor

@wgtmac@dongjoon-hyun I'm ready to review now, please take a look when you're free~

@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you, @ffacs .

Comment threadc++/include/orc/Statistics.hh
Comment threadc++/include/orc/Statistics.hh Outdated
* This file contains code adapted from the Apache Arrow project.
*
* Original source:
* https://github.com/apache/arrow/blob/main/cpp/src/parquet/geospatial/statistics.h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a tag based location instead of the main branch because it changes always.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no tags that contain this patch yet.

Comment threadc++/src/Geospatial.cc
* This file contains code adapted from the Apache Arrow project.
*
* Original source:
* https://github.com/apache/arrow/blob/main/cpp/src/parquet/geospatial/statistics.cc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a tag based location instead of the main branch because it changes always.

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM.

Comment threadc++/include/orc/Geospatial.hh Outdated
Comment threadc++/include/orc/Type.hh
Comment threadc++/include/orc/Type.hh Outdated
Comment threadc++/include/orc/Type.hh Outdated
Comment on lines +77 to +78
virtual const std::string& getCRS() const = 0;
virtual geospatial::EIAlgo getEIAlgo() const = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
virtualconst std::string& getCRS() const = 0;
virtual geospatial::EIAlgo getEIAlgo() const = 0;
virtualconst std::string& getCrs() const = 0;
virtual geospatial::EdgeInterpolationAlgorithm getAlgorithm() const = 0;

It would be good to add comment to say these two functions are for geometry & geography types only.

Comment threadc++/src/ColumnWriter.cc Outdated
Comment threadc++/src/Geospatial.cc Outdated
Comment threadc++/src/Geospatial.cc Outdated
Comment threadc++/src/Geospatial.cc
void WKBGeometryBounder::mergeGeometryInternal(WKBBuffer* src, bool recordWkbType) {
uint8_t endian = src->ReadUInt8();
bool swap = endian != 0x00;
if (isLittleEndian()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can use if constexpr (std::endian::native == std::endian::little)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::endian requires C++20, we are using c++17 now.

Comment threadc++/src/Geospatial.hh Outdated
@dongjoon-hyun

Copy link
Copy Markdown
Member

Is this ready or do we need more revision, @ffacs and @wgtmac ?

Comment threadc++/src/TypeImpl.cc Outdated
@wgtmac

Copy link
Copy Markdown
Member

Is this ready or do we need more revision, @ffacs and @wgtmac ?

My only concern is the name of public api: https://github.com/apache/orc/pull/2269/files#r2184135226. It is better to use getCrs() and getAlgorithm()/getEdgeAlgorithm()

@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you everyone, @ffacs , @williamhyun , @wgtmac .
Merged to main/2.2.

dongjoon-hyun pushed a commit that referenced this pull request Jul 14, 2025
What changes were proposed in this pull request?
Support Geometry and Geography types for c++ side
Why are the changes needed?
Add support for Geometry and Geography types
How was this patch tested?
UT passed
Was this patch authored or co-authored using generative AI tooling?
No
Closes#2269 from ffacs/geo.
Authored-by: ffacs <ffacs520@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit ca9bb59)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun pushed a commit to apache/spark that referenced this pull request Jul 30, 2025
### What changes were proposed in this pull request?
This PR aims to upgrade ORC to 2.2.0. 2.2.0 RC1 is currently under voting.
### Why are the changes needed?
Apache ORC 2.2.0 is a new feature release.
- https://github.com/apache/orc/releases/tag/v2.2.0
- apache/orc#2032
- apache/orc#2338
- apache/orc#2269
- apache/orc#2249
- apache/orc#2144
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes#51676 from williamhyun/ORC-2.2.0.
Authored-by: William Hyun <william@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ffacs@dongjoon-hyun@wgtmac@williamhyun