You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Pereslegin (Jira)" <ji...@apache.org> on 2025/07/01 15:28:00 UTC

[jira] [Updated] (IGNITE-25811) Sql. Forbid use of an expression as interval string

     [ https://issues.apache.org/jira/browse/IGNITE-25811?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pavel Pereslegin updated IGNITE-25811:
--------------------------------------
    Description: 
SQL defines an interval literal as follows:
{code:sql}
<interval literal> ::=
INTERVAL [ <sign> ] <interval string> <interval qualifier>
<interval string> ::=
<quote> <unquoted interval string> <quote>
{code}

However, calcite does allow expression as the "interval string".

This allows for example use column value as the interval string, e.g.

{code:sql}
CREATE TABLE t(id INT PRIMARY KEY);
INSERT INTO t VALUES (1), (2), (3);

SELECT INTERVAL id YEAR FROM t; -- returns P3Y, P2Y, P1Y
{code}

But it also leads to inconsistency and hidden errors.
For example: https://issues.apache.org/jira/browse/CALCITE-6114

The solution is to forbid the use of an expression as the interval string during the validation phase.

  was:
SQL defines an interval literal as follows:
{code:sql}
<interval literal> ::=
INTERVAL [ <sign> ] <interval string> <interval qualifier>
<interval string> ::=
<quote> <unquoted interval string> <quote>
{code}

However, calcite does allow expression as an "interval string".

This allows for example use column value as interval string, e.g.

{code:sql}
CREATE TABLE t(id INT PRIMARY KEY);
INSERT INTO t VALUES (1), (2), (3);

SELECT INTERVAL id YEAR FROM t; -- returns P3Y, P2Y, P1Y
{code}

But it also leads to inconsistency and hidden errors.
For example: https://issues.apache.org/jira/browse/CALCITE-6114

The solution is to forbid the use of an expression as a interval string during the validation phase.


> Sql. Forbid use of an expression as interval string
> ---------------------------------------------------
>
>                 Key: IGNITE-25811
>                 URL: https://issues.apache.org/jira/browse/IGNITE-25811
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql, sql ai3
>            Reporter: Pavel Pereslegin
>            Priority: Major
>
> SQL defines an interval literal as follows:
> {code:sql}
> <interval literal> ::=
> INTERVAL [ <sign> ] <interval string> <interval qualifier>
> <interval string> ::=
> <quote> <unquoted interval string> <quote>
> {code}
> However, calcite does allow expression as the "interval string".
> This allows for example use column value as the interval string, e.g.
> {code:sql}
> CREATE TABLE t(id INT PRIMARY KEY);
> INSERT INTO t VALUES (1), (2), (3);
> SELECT INTERVAL id YEAR FROM t; -- returns P3Y, P2Y, P1Y
> {code}
> But it also leads to inconsistency and hidden errors.
> For example: https://issues.apache.org/jira/browse/CALCITE-6114
> The solution is to forbid the use of an expression as the interval string during the validation phase.



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