[
https://issues.apache.org/jira/browse/CALCITE-5677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17717858#comment-17717858
]
Tanner Clary commented on CALCITE-5677:
---------------------------------------
Yeah, the issue is solely with the FROM/FOR, not SUBSTR vs. SUBSTRING. Oracle
and dialects like Postgres, Presto, and Firebolt all seem to have clauses in
their dialect classes
([example|https://github.com/apache/calcite/blob/3326475c766267d521330006cc80730c4e456191/core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java#L148])
that makes sure they use SUBSTR over SUBSTRING.
As for different semantics when it comes to non-positive pos values, I'm happy
to do more research but this specific change I think leaves the behavior as it
was before (whether right or wrong).
> SUBSTR signature incorrect for BigQuery
> ---------------------------------------
>
> 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)