[
https://issues.apache.org/jira/browse/CALCITE-5276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17603811#comment-17603811
]
Bertil Chapuis commented on CALCITE-5276:
-----------------------------------------
Thank you for the helping hand, it was what I needed to make progress. I have
now been able to simplify a lot of tests in the spatial.iq file. I think the PR
is almost ready.
[https://github.com/apache/calcite/pull/2905]
In addition to implicit conversion from char, I also added implicit conversion
from binary. To cover this case, I added the following query to spatial.iq.
{{SELECT ST_AsWKT(CAST(ST_AsBinary('LINESTRING (1 2, 3 4)') as binary))}}
Weirdly, ST_AsBinary seems to return a value of type OTHER whereas the
signature uses a ByteString (exception below). Is this a bug?
{{java.sql.SQLException: Error while executing SQL "SELECT
ST_AsWKT(CAST(ST_AsBinary('LINESTRING (1 2, 3 4)') as binary))": From line 1,
column 17 to line 1, column 68: Cast function cannot convert value of type
OTHER to type BINARY(1)}}
> Implicitly convert strings to geometries
> ----------------------------------------
>
> Key: CALCITE-5276
> URL: https://issues.apache.org/jira/browse/CALCITE-5276
> Project: Calcite
> Issue Type: Improvement
> Reporter: Bertil Chapuis
> Assignee: Bertil Chapuis
> Priority: Minor
>
> Postgis and H2GIS implicitly transform strings into a geometries so that one
> can write the following query:
> {{SELECT ST_AsText('POINT(-71.064544 42.28787)');}}
> Instead of:
> {{SELECT ST_AsText(ST_GeomFromText('POINT(-71.064544 42.28787)'));}}
> supports this kind of conversion. Should I introduce a new SqlTypeTranform
> (TO_GEOMETRY)? Thanks a lot for your help, I'm still discovering the
> internals of calcite.
> The idea would be to introduce a SqlTypeTransform, change the
> SqlTypeAssignmentRule (see CALCITE-3550), add tests in TypeCoercionTest, and
> update the doc.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)