You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "adamaps (via GitHub)" <gi...@apache.org> on 2024/04/19 18:01:47 UTC
[I] Unable to use sedona.global.charset in ShapefileReader [sedona]
adamaps opened a new issue, #1345:
URL: https://github.com/apache/sedona/issues/1345
## Expected behavior
`ShapefileReader.readToGeometryRDD(sedona_context, shp_file)` should use the `sedona.global.charset` configuration property set in the spark session when reading shapefiles containing non-ASCII characters.
E.g. A shapefile containing an attribute value `"Ariñiz/Aríñez"` should appear in a dataframe as `"Ariñiz/Aríñez"`.
## Actual behavior
`ShapefileReader.readToGeometryRDD(sedona_context, shp_file)` is not using the charset configuration property set in the spark context.
E.g. A shapefile containing an attribute value `"Ariñiz/Aríñez"` appears in a dataframe as `"Ariñiz/ArÃñez"` instead.
## Steps to reproduce the problem
```python
from pyspark.conf import SparkConf
from pyspark.sql import SparkSession
from sedona.core.formatMapper.shapefileParser import ShapefileReader
from sedona.spark import SedonaContext
from sedona.utils.adapter import Adapter
conf = SparkConf()
conf.set("sedona.global.charset", "utf8")
spark = SparkSession.builder.config(conf=conf).getOrCreate()
sedona = SedonaContext.create(spark)
sedona_context = sedona.sparkContext
shp_file = '[aws s3 path to shapefile]'
shp_rdd = ShapefileReader.readToGeometryRDD(sedona_context, shp_file)
shp_df = Adapter.toDf(shp_rdd, sedona)
```
I can confirm that `("sedona.global.charset", "utf8")` appears in the configuration settings by using:
```python
print(sedona_context.getConf().getAll())
```
I also tried setting the charset property after creating the sedona context as follows (although this appears to be an older solution):
```python
sedona_context.setSystemProperty("sedona.global.charset", "utf8")
```
Please confirm how to set this configuration property correctly.
## Settings
Sedona version = 1.5.1
Apache Spark version = 3.3.0
API type = Python
Python version = 3.10
Environment = AWS Glue 4.0 using `sedona-spark-shaded-3.0_2.12-1.5.1.jar` and `geotools-wrapper-1.5.1-28.2.jar`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sedona.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Unable to use sedona.global.charset in ShapefileReader [sedona]
Posted by "Kontinuation (via GitHub)" <gi...@apache.org>.
Kontinuation commented on issue #1345:
URL: https://github.com/apache/sedona/issues/1345#issuecomment-2079653481
`sedona.global.charset` has to be set as a Java system property. You can try setting the following spark configurations:
```
spark.driver.extraJavaOptions -Dsedona.global.charset=utf8
spark.executor.extraJavaOptions -Dsedona.global.charset=utf8
```
The dataframe loaded from the sample shapefile:
```
+--------------------+--------------------+--------------------+--------------------+
| geometry| ID| Name| Name_ASCII|
+--------------------+--------------------+--------------------+--------------------+
|MULTIPOLYGON (((-...|01015 |Ariñiz/Aríñez ...|Ariniz/Arinez ...|
+--------------------+--------------------+--------------------+--------------------+
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Unable to use sedona.global.charset in ShapefileReader [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu closed issue #1345: Unable to use sedona.global.charset in ShapefileReader
URL: https://github.com/apache/sedona/issues/1345
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Unable to use sedona.global.charset in ShapefileReader [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on issue #1345:
URL: https://github.com/apache/sedona/issues/1345#issuecomment-2067085806
@adamaps If you are running Sedona in a cluster mode, this needs to be set via `spark.executorEnv.[EnvironmentVariableName]`: https://spark.apache.org/docs/latest/configuration.html
In your case, you might want to try this:
```
spark.executorEnv.sedona.global.charset utf8
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Unable to use sedona.global.charset in ShapefileReader [sedona]
Posted by "adamaps (via GitHub)" <gi...@apache.org>.
adamaps commented on issue #1345:
URL: https://github.com/apache/sedona/issues/1345#issuecomment-2071087493
Thank you for the quick response, @jiayuasu !
I tested the following in `client mode` before creating the Sedona `SparkSession`/`SparkContext` (via a local Docker container):
```python
conf = SparkConf()
conf.set("sedona.global.charset", "utf8") # I have other conf settings not shown here
spark = SparkSession.builder.config(conf=conf).getOrCreate()
sedona = SedonaContext.create(spark)
```
And I tested both of the following in `cluster mode` after creating the Sedona `SparkSession`/`SparkContext` (via AWS Glue):
```python
spark.conf.set("spark.executorEnv.sedona.global.charset","utf8")
sedona.conf.set("spark.executorEnv.sedona.global.charset","utf8")
```
Unfortunately I still see the same issue in both cases.
Are you able to replicate (or reject) the issue using the attached shapefile sample?
[shapefile_sample.zip](https://github.com/apache/sedona/files/15069264/shapefile_sample.zip)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Unable to use sedona.global.charset in ShapefileReader [sedona]
Posted by "adamaps (via GitHub)" <gi...@apache.org>.
adamaps commented on issue #1345:
URL: https://github.com/apache/sedona/issues/1345#issuecomment-2085903669
Thank you, @Kontinuation! 🎉
I can confirm that setting the following configuration parameter in PySpark worked for my local setup. And thanks @jiayuasu for updating the docs.
```python
conf.set("spark.driver.extraJavaOptions", "-Dsedona.global.charset=utf8")
```
Running on AWS/Glue is still causing issues, but this seems specific to our setup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org