cgqfzy opened a new issue, #821:
URL: https://github.com/apache/sedona/issues/821

   ### 1. start spark session local
   ```shell
   bin/spark-sql --jars 
/mypath/sedona-spark-shaded-3.0_2.12-1.4.0.jar,/mypath/sedona-viz-3.0_2.12-1.4.0.jar,/mypath/sedona-sql-3.0_2.12-1.4.0.jar,/mypath/sedona-common-1.4.0.jar,/mypath/postgresql-42.2.27.jar,/mypath/geotools-wrapper-1.4.0-28.2.jar
 \
     --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
     --conf 
spark.kryo.registrator=org.apache.sedona.viz.core.Serde.SedonaVizKryoRegistrator
 \
     --conf 
spark.sql.extensions=org.apache.sedona.viz.sql.SedonaVizExtensions,org.apache.sedona.sql.SedonaSqlExtensions
 \
     --master local[4]
   ```
   as described in 
https://sedona.apache.org/latest-snapshot/tutorial/sql-pure-sql/ 
   
   ### 2. tables or views fileds defined by  secona function is **geometry**,  
but **geometry** type could not directly defined in other tables
   ```sql
   CREATE TABLE IF NOT EXISTS pointraw (c0 string, c1 string) 
   USING csv 
   OPTIONS(header='false') 
   LOCATION 'mydatapath/testpoint.csv';
   
   CREATE TABLE IF NOT EXISTS polygonraw (c0 string, c1 string, c2 string, c3 
string) 
   USING csv 
   OPTIONS(header='false') 
   LOCATION 'mydatapath/testenvelope.csv';
   
   CREATE OR REPLACE TEMP VIEW pointdata AS
     SELECT ST_Point(cast(pointraw._c0 as Decimal(24,20)), cast(pointraw._c1 as 
Decimal(24,20))) AS pointshape
     FROM pointraw;
   
   CREATE OR REPLACE TEMP VIEW polygondata AS
     select ST_PolygonFromEnvelope(cast(polygonraw._c0 as Decimal(24,20)),
           cast(polygonraw._c1 as Decimal(24,20)), cast(polygonraw._c2 as 
Decimal(24,20)), 
           cast(polygonraw._c3 as Decimal(24,20))) AS polygonshape 
     FROM polygonraw;
   
   DESC VIEW pointdata ;
   -- return 
   -- pointshape        geometry        NULL
   DESC VIEW polygondata ;
   -- return 
   -- polygonshape      geometry        NULL
   
   
   CREATE TEMPORARY table test_polygon (
       geom geometry
   )
   using org.apache.spark.sql.jdbc
   options (
       url='jdbc:postgresql://xxxxxxxx:5432/xxxx',
       driver='org.postgresql.Driver',
       dbtable='public.test_polygon',
       user='xxxx',
       password='xxxx'
   );
   
   ```
   
   
![image](https://user-images.githubusercontent.com/3734588/233251701-903c2e32-f4d2-4c7c-860d-b8a972f36c9d.png)
   <img width="1482" alt="image" 
src="https://user-images.githubusercontent.com/3734588/233252057-7d5c4f8e-8942-464f-9d53-798645eb29ff.png";>
   
   ### 3. question
   1. how could I defined **geometry** type in spark sql ?
   2. I have geometry type field in postgresql, could I write the field when a 
geometry type returned in the case of sedona function used?
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to