Skip to content

Conversation

@yutannihilation
Copy link
Contributor

Fix #280

I guess there are more functions that need similar fix, but this only addresses ST_Collect_Agg(), which looks straightforward.

> SELECT ST_Collect_Agg(ST_GeogPoint(0, 1));
┌─────────────────────────────────────────────────┐
│ st_collect_agg(st_geogpoint(Int64(0),Int64(1))) │
│                    geography                    │
╞═════════════════════════════════════════════════╡
│ MULTIPOINT((0 1))                               │
└─────────────────────────────────────────────────┘

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you!

I have a slight preference for registering two kernels to do this (or rather: the same parameterized kernel twice)...the dispatch code added here duplicates some logic we have to do the same thing already. I know it is silly but struct STCollectAggr { is_geography: bool} + vec![Arc::new(STCollectAggr {is_geography: true}, STCollectAggr {is_geography: false})], would let us reuse that.

There are a few unrealized benefits of the kernel system that aren't well documented yet...we can do an optimization where we resolve the kernel at the end of the planning stage to prevent the kernel from being resolved for every batch during execution (which is what happens now). We could also leverage this to validate documentation (the kernel list is basically a list of mappings from input type -> output type).

Comment on lines 73 to 80
let geom_matcher = ArgMatcher::new(vec![ArgMatcher::is_geometry()], WKB_GEOMETRY);
let geog_matcher = ArgMatcher::new(vec![ArgMatcher::is_geography()], WKB_GEOGRAPHY);
for matcher in [geom_matcher, geog_matcher] {
if let result @ Ok(Some(_)) = matcher.match_args(args) {
return result;
}
}
Ok(None)
Copy link
Member

Choose a reason for hiding this comment

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

This is very similar to what the SedonaAggregateUDF does when resolving the SedonaAccumulator based on the input arguments.

@yutannihilation
Copy link
Contributor Author

Thanks for the hint, I'll implement so! (Probably later this week or next year)

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you!

@paleolimbot paleolimbot merged commit a43c9fc into apache:main Jan 5, 2026
14 checks passed
@yutannihilation yutannihilation deleted the fix/st_collect_agg-geography branch January 5, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ST_Collect() on a Geography returns a Geometry

2 participants