Skip to content
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

[SEDONA-157] Add coordinate accessors to the Flink API #677

Merged
merged 2 commits into from
Sep 4, 2022

Conversation

sekikn
Copy link
Contributor

@sekikn sekikn commented Sep 4, 2022

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

This PR adds ST_X, ST_Y and ST_Z to the Flink API.

How was this patch tested?

  • Ran mvn clean install locally
  • Ran mkdocs serve and checked the generate document

Did this PR include necessary documentation updates?

  • Yes, I am adding a new API. I am using the 1.3.0 in since vX.Y.Z format.

@@ -70,6 +70,27 @@ public static double length(Geometry geometry) {
return geometry.getLength();
}

public static Double x(Geometry geometry) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be the boxed type instead of the native double like the other functions return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ST_X, ST_Y and ST_Z should return null if the first argument is not a Point, so we have to check the input type somewhere. I chose to do that in the common functions, because if they can direcly return null by using a boxed type, we can simply wrap it with InferredUnaryExpression in the Spark SQL functions. But as you pointed out, returning boxed type looks somewhat strange. Should I change the common functions to return a primitive value? In that case, we have to use UnaryGeometryExpression instead of InferredUnaryExpression so the code will become a bit verbose. Either is fine with me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right that makes sense then, nvm

@@ -265,6 +265,27 @@ public void testIsEmpty() {
assertEquals(false, result);
}

@Test
public void testX() {
Copy link
Member

@jiayuasu jiayuasu Sep 4, 2022

Choose a reason for hiding this comment

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

Can you use the same test in testZ for testX and testY so testX and testY don't need to use point_real?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR. Thanks for the review!

@jiayuasu jiayuasu changed the title SEDONA-157: Add coordinate accessors to the Flink API [SEDONA-157] Add coordinate accessors to the Flink API Sep 4, 2022
@jiayuasu jiayuasu added this to the sedona-1.3.0 milestone Sep 4, 2022
@jiayuasu jiayuasu merged commit ec68445 into apache:master Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants