[ 
https://issues.apache.org/jira/browse/CALCITE-6239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17824651#comment-17824651
 ] 

Bertil Chapuis commented on CALCITE-6239:
-----------------------------------------

[~julianhyde] I added the second argument for the type familiy to the 
getJavaClass method to get a sense of the impacts brought by this change. It 
looks like many callers are only aware of the Class and not the type family. In 
these cases, do you have an idea of what would be the right approach to get the 
family? I was tempted to create a JavaType with a the class as a parameter, but 
then realized it doesn't really make sense as we probably don't want to touch 
the CLASS_FAMILIES constant of RelDataTypeFactoryImpl.

Also, @Parameter annotation is used annotate arguments in the 
SpatialTypeFunctions class. Shouldn't we annotate the return types as well for 
nested function calls?

> Add a PostGIS dialect that supports ST_ functions
> -------------------------------------------------
>
>                 Key: CALCITE-6239
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6239
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core, spatial
>            Reporter: Bertil Chapuis
>            Assignee: Bertil Chapuis
>            Priority: Minor
>              Labels: pull-request-available
>
> Calcite implements support for spatial types (geometry, point, etc.) and 
> spatial functions (ST_), and it can connect to PostGIS via a JdbcSchema. 
> However, the Postgresql dialect does not currently handle spatial types and 
> functions. As a result, Calcite tries to execute the spatial functions at the 
> level of the JVM instead of pushing them down to postgis.
> As a result, the following query gets executed, but the type of the geom 
> column is incorrect:
> SELECT id, geom FROM public.spatial_table
> The following query fails with a ClassCastException as Calcite tries to use 
> the java implementation of the ST_SRID function:
> SELECT id, ST_SRID(geom) FROM public.spatial_table
> java.lang.ClassCastException: class org.postgresql.util.PGobject cannot be 
> cast to class org.locationtech.jts.geom.Geometry 
> (org.postgresql.util.PGobject and org.locationtech.jts.geom.Geometry are in 
> unnamed module of loader 'app')
> In my current understanding, this issue could be addressed with a new 
> PostgisSqlDialect that extends PostgresqlSqlDialect and adds support for 
> spatial types and functions. Here is a tentative roadmap:
> - Add all the spatial functions to the SqlKind class
> - Create a PostgisSqlDialect class that extends PostgresqlSqlDialect
> - Add support for the spatial types (geometry) by overriding the getCastSpec 
> method of the SqlDialect class
> - Add support for the spatial functions by overriding the supportsFunction 
> method of the SqlDialect class
> - Add support for the spatial aggregate functions by overriding the 
> supportsAggregateFunction method of the SqlDialect class



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to