[
https://issues.apache.org/jira/browse/CALCITE-6576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17882134#comment-17882134
]
Julian Hyde edited comment on CALCITE-6576 at 9/16/24 5:48 PM:
---------------------------------------------------------------
The parser change looks good. However, there is no validator support.
Invalid queries such as the following will pass through the parser and produce
unpredictable results in the validator or later:
{code}
UPDATE emp AS e SET a.b.c.d.deptno = 10;
UPDATE emp AS e SET dept.deptno = 10;
{code}
And valid queries such as the following will pass through the parser and
probably fail:
{code}
UPDATE scott.emp AS emp SET scott.emp.deptno = 10;
UPDATE scott.emp AS e SET emp.deptno = 10;
UPDATE scott.emp AS e SET e.deptno = 10;
UPDATE emp AS e SET emp.deptno = 10;
UPDATE emp AS e SET e.deptno = 10;
{code}
The following should be invalid (see SqlValidatorTest.testSchemaTableColumn for
details):
{code}
UPDATE scott.emp AS e SET scott.emp.deptno = 10; # gives "Table 'SCOTT.EMP' not
found"
UPDATE scott.emp AS e SET scott.deptno.deptno = 10;# "Table 'SCOTT.DEPT' not
found"
{code}
Can we have a follow-up PR that does the validator work?
was (Author: julianhyde):
The parser change looks good. However, there is no validator support.
Invalid queries such as the following will pass through the parser and produce
unpredictable results in the validator or later:
{code}
UPDATE emp AS e SET a.b.c.d.deptno = 10;
UPDATE emp AS e SET dept.deptno = 10;
{code}
And valid queries such as the following will pass through the parser and
probably fail:
{code}
UPDATE scott.emp AS e SET scott.emp.deptno = 10;
UPDATE scott.emp AS e SET emp.deptno = 10;
UPDATE scott.emp AS e SET e.deptno = 10;
UPDATE emp AS e SET emp.deptno = 10;
UPDATE emp AS e SET e.deptno = 10;
{code}
Can we have a follow-up PR that does the validator work?
> In SET clause of UPDATE statement, allow column identifiers to be prefixed
> with table alias
> -------------------------------------------------------------------------------------------
>
> Key: CALCITE-6576
> URL: https://issues.apache.org/jira/browse/CALCITE-6576
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.37.0
> Reporter: Niels Pardon
> Assignee: Niels Pardon
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.38.0
>
>
> The Apache Calcite SQL parser does allow to assign a table alias within an
> UPDATE statement but the table alias can currently not be used with the
> column identifiers within the SET section.
> The following can be parsed successfully:
> {code:sql}
> UPDATE mytable AS t SET ID=1;
> UPDATE mytable t SET ID=1;
> {code}
> But the parser fails as soon as the table alias is used with the column
> identifier in the SET section:
> {code:sql}
> UPDATE mytable AS t SET t.ID=1;
> UPDATE mytable t SET t.ID=1;
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)