You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Tanner Clary (Jira)" <ji...@apache.org> on 2023/04/28 18:55:00 UTC

[jira] [Comment Edited] (CALCITE-5677) Remove unparseCall override in SqlSubstringFunction

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

Tanner Clary edited comment on CALCITE-5677 at 4/28/23 6:54 PM:
----------------------------------------------------------------

[~julianhyde] [~dmsysolyatin] After reviewing a number of dialects, including those Dmitry mentioned among others, I think we should remove the override in {{SqlSubstringFunction}}. Up to this point, I have not found a dialect that does not support comma-separated arguments for the {{SUBSTR}}/{{SUBSTRING}} functions. I still think it could be helpful to potentially add some more tests but as of now, I think the {{SUBSTRING(.. FROM .. FOR ..)}} signature should be treated as an exception rather than the norm. 

I have updated my PR to reflect these thoughts, please let me know if either of you have any other thoughts. Thanks!


was (Author: JIRAUSER298151):
[~julianhyde] [~dmsysolyatin] After reviewing a number of dialects, including those Dmitry mentioned among others, I think we should remove the override in {{SqlSubstringFunction}}. Up to this point, I have not found a dialect that does not support comma-separated arguments for the {{SUBSTR}}/{{SUBSTRING}} functions. I still think it could be helpful to potentially add some more tests but as of now, I think the {{SUBSTRING(.. FROM .. FOR ..)}} signature should be treated as an exception rather than the norm. Please let me know if either of you have any other thoughts. Thanks!

> Remove unparseCall override in SqlSubstringFunction
> ---------------------------------------------------
>
>                 Key: CALCITE-5677
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5677
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Tanner Clary
>            Assignee: Tanner Clary
>            Priority: Major
>              Labels: pull-request-available
>
> BigQuery's {{SUBSTR(value, position[, length])}} function currently gets translated to the standard {{SUBSTRING(value FROM position[ FOR length])}}. BigQuery expects the arguments to be comma-separated rather than the use of the {{FROM}} and {{FOR}} keywords. 
> EXAMPLE: {{SUBSTR('hello', 2)}} would get translated to {{SUBSTRING('hello' FROM 2)}} which BigQuery does not recognize.
> Hive addresses this issue by adding onto {{HiveSqlDialect#unparseCall}} method. I believe BigQuery should do something similar to avoid this incorrect translation. The docs for the {{SUBSTR}} (and alias {{SUBSTRING}}) function may be found [here|https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#substr].
> I will open a PR shortly that implements my suggestion and adds a couple of tests as well.



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