You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/12/07 02:08:00 UTC

[jira] [Commented] (CALCITE-4427) Make SUBSTRING operator comply with ISO standard SQL

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

Julian Hyde commented on CALCITE-4427:
--------------------------------------

This is going to be a breaking change (albeit minor):
* In 1.26, {{SUBSTRING('abcde' FROM -4 FOR 2)}} returned 'bc' (behavior compatible with BigQuery)
* In 1.27, {{SUBSTRING('abcde' FROM -4 FOR 2)}} will return 'ab' (behavior compatible with ISO standard SQL and PostgreSQL)

In 1.27, you will be able to override the default by setting 'semantics=bigquery' in the connect-string parameters. This will restore 1.26 behavior.

*Rationale*: Calcite always aims to be compatible with (or a superset of) ISO standard SQL. We made a mistake in introducing non-standard behavior in CALCITE-2572.

Also in this change, there will be {{SUBSTR}} functions compatible with BigQuery, Oracle, MySQL, PostgreSQL. These functions all have slightly different semantics. Whether a {{SUBSTR}} function is available, and what are its semantics, depends on the value of the {{fun}} connect-string parameter of that connection.

Depending on the combination of {{semantics}} and {{fun}} parameters, {{SUBSTRING}} and {{SUBSTR}} with the same parameters may give different results.

*Rationale*: Given that {{SUBSTRING}} is standard, and present in all dialects, it seemed unwise to change its behavior based on the {{fun}} parameter. The new {{semantics}} parameter was added to control it.

If people have objections to the above described behavior, please speak up very soon.

> Make SUBSTRING operator comply with ISO standard SQL
> ----------------------------------------------------
>
>                 Key: CALCITE-4427
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4427
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Priority: Major
>
> Make {{SUBSTRING}} operator comply with ISO standard SQL. It currently complies with BigQuery standard SQL, which gives different behavior when start is negative. See discussion in CALCITE-4408.
> Add an option to get the BigQuery behavior, for those who want it.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)