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

Tranforming array<array<double>> to ST_MultiPolygon #132

Closed
Andarius opened this issue Oct 23, 2017 · 3 comments
Closed

Tranforming array<array<double>> to ST_MultiPolygon #132

Andarius opened this issue Oct 23, 2017 · 3 comments
Labels

Comments

@Andarius
Copy link

Andarius commented Oct 23, 2017

I'm trying to load a valid Geojson file using SPARK SQL and then transforming the coordinates to ST_MultiPolygon.

The jars I use are:

esri-geometry-api-2.0.0.jar
spatial-sdk-json-1.2.0.jar
spatial-sdk-hive-1.2.0.jar

The schema of the input data is:

 |-- geometry: struct (nullable = true)
 |    |-- coordinates: array (nullable = true)
 |    |    |-- element: array (containsNull = true)
 |    |    |    |-- element: array (containsNull = true)
 |    |    |    |    |-- element: array (containsNull = true)
 |    |    |    |    |    |-- element: double (containsNull = true)
 |    |-- type: string (nullable = true)
 |-- properties: struct (nullable = true)
 |-- type: string (nullable = true)

The process fails when I try the following:

SELECT
    st_multipolygon(geometry.coordinates[0][0]) as geo
FROM test

I get:

No handler for Hive UDF 'com.esri.hadoop.hive.ST_MultiPolygon': org.apache.hadoop.hive.ql.exec.NoMatchingMethodException: No matching method for class com.esri.hadoop.hive.ST_MultiPolygon with (array<array<double>>). Possible choices: _FUNC_(array<array<double>>) _FUNC_(string) ;

So I pass an array<array> and it expects an array<array>.

It works if I try:

SELECT
    st_multipolygon(geometry.coordinates[0][0][0], geometry.coordinates[0][0][1], ...) as geo
FROM test

Any idea of what's wrong (or what I'm doing wrong ?)

@randallwhitman
Copy link
Contributor

Spatial-Framework documentation says ST_MultiPolygon(array(x1, y1, x2, y2, ... ), array(x1, y1, x2, y2, ... ), ... ), so it looks like st_multipolygon(geometry.coordinates[0][0][0], geometry.coordinates[0][0][1], ...) passes array<double> as expected and works correctly.

Maybe the only oddity is - is Spark-SQL presenting a botched error message?

@randallwhitman
Copy link
Contributor

Cross-reference #36, #126.

@randallwhitman
Copy link
Contributor

Try ST_GeomFromGeoJson.

@Andarius Andarius closed this as completed Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants