Alexander Arlievsky
Alexander Arlievsky

Reputation: 1

Apache Sedona TypeError: 'JavaPackage' object is not callable error

I am trying to use Sedona from pyspark, and got blocked by some configuration problem. I have Ubuntu with python 3.9.5 pyspark 3.3.2 Sedona 1.5.3

pyspark configuration includes:

from sedona.spark import *
from sedona.sql import st_constructors as stc

.set('spark.jars.packages',
'org.apache.sedona:sedona-spark-shaded-3.0_2.12:1.5.3,org.datasyslab:geotools-wrapper:1.5.3-28.2')\
.set('spark.jars.repositories', 
   'https://artifacts.unidata.ucar.edu/repository/unidata-all')\
.set("spark.sql.extensions", "org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,org.apache.sedona.viz.sql.SedonaVizExtensions,org.apache.sedona.sql.SedonaSqlExtensions")\

I am running in local mode (no cluster). SQL environment works as expected:

df = spark.sql("SELECT array(0.0, 1.0, 2.0) AS values")
df.createOrReplaceTempView("inputtable")

df = spark.sql("SELECT ST_Point(ARRAY_MIN(values), ARRAY_MAX(values)) as point from inputtable")
 

when I try to use python functions instead of SQL, it fails:

df = df.select(stc.ST_Point(1.0, 3.0).alias("point"))

Traceback (most recent call last):
  File "/home/XXXXX/code/sedona_test/sedona-main.py", line 218, in run
    df = df.select(stc.ST_Point(1.0, 3.0).alias("point"))
  File "/home/XXXXX/.local/lib/python3.9/site-packages/sedona/sql/dataframe_api.py", line 156, in validated_function
    return f(*args, **kwargs)
  File "/home/XXXXX/.local/lib/python3.9/site-packages/sedona/sql/st_constructors.py", line 177, in ST_Point
    return _call_constructor_function("ST_Point", (x, y))
  File "/home/XXXXX/.local/lib/python3.9/site-packages/sedona/sql/dataframe_api.py", line 65, in call_sedona_function
    jc = jfunc(*args)
TypeError: 'JavaPackage' object is not callable

I am sure there is some version mismatch, but where ????

tried to run pure SQL and it works, so basic sedona is configured properly.

Upvotes: 0

Views: 184

Answers (1)

Jia Yu - Apache Sedona
Jia Yu - Apache Sedona

Reputation: 304

I guess you don't have to use from sedona.sql import st_constructors as stc.

Just from sedona.spark import *, then call ST_Point?

Upvotes: 0

Related Questions