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

Improved error handling for spatial points #7120

Merged
merged 4 commits into from May 17, 2016

Conversation

pontusmelke
Copy link
Contributor

@pontusmelke pontusmelke commented May 13, 2016

  • point( {x: 0.1, y: 1.1}) should not fail with java.util.NoSuchElementException but have a proper error message and type
  • point({x: 0.1, y: 1.1, crs: "NOT_EXISING"}) should fail with proper error message and type instead of being a scala.MatchError
  • point({x: 1, y: 2, crs: "cartesian"}) should be allowed and not produce a java.lang.ClassCastException
  • Bolt should temporarily fail on points with a nice error message, until we have proper support for points in Bolt

Instead of failing with `java.util.NoSuchElementException` we should fail with
proper error types  and error messages when the user provides syntactically
invalid points
@pontusmelke pontusmelke changed the title Proper error handling for spatial points Improved error handling for spatial points May 13, 2016
While we wait for properly handle points in bolt we should at least fail
somewhat gracefully instead of the hard crash we currently do.

test("should fail properly if unknown coordinate system") {
a [SyntaxException] shouldBe thrownBy(executeWithAllPlanners("RETURN point({params}) as point",
"params" -> Map("y" -> 1.0, "crs" -> "WGS-1337")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this test have an x coordinate? The failure condition is the invalid value of the crs parameter, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess a better option would be to skip the y coordinate, and just supply an illegal crs value.

@@ -666,6 +666,18 @@ class SemanticErrorAcceptanceTest extends ExecutionEngineFunSuite {
"A single relationship type must be specified for MERGE (line 1, column 9 (offset: 8))")
}

test("give a nice error message when missing crs in cartesian point") {
executeAndEnsureError("RETURN point({x: 2.3, y: 4.5}) as point",
"A cartesian point must contain a 'crs' (coordinate reference system) (line 1, column 14 (offset: 13))")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the error. Without a CRS, this will get WGS84 which makes it a geographic point, not a cartesian point. Then the error should be 'A geographic point needs latitude and longitude', right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that how you see it, is the names of the coordinates or the crs the most important thing? Before this change all we got was a java.util.NoSuchElementException?

I would think if a user put in an x and a y there the intention is to use a cartesian point not a geographic point don't you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I changed my mind. I think it would be better to keep your error message, and make the xy/latlng the primary criteria for geo/cartesian, which is what I assume you thought was the case. I think your approach is better, but it requires that we no longer assume WGS84 default for missing crs, but have two defaults, one for xy and one for latlng. That change does not need to be made as part of this PR either, as it is just a small refinement to the case of missing crs.

@systay systay merged commit 53fb160 into neo4j:3.0 May 17, 2016
@craigtaverner craigtaverner deleted the 3.0-points-error-handling branch May 18, 2016 16:18
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

5 participants