Vladimir Sitnikov created CALCITE-7891:
------------------------------------------
Summary: Error for a qualified name in DESCRIPTOR says the
argument must be an identifier
Key: CALCITE-7891
URL: https://issues.apache.org/jira/browse/CALCITE-7891
Project: Calcite
Issue Type: Improvement
Components: core
Affects Versions: 1.42.0
Reporter: Vladimir Sitnikov
{code:sql}
select * from table(tumble(table orders, descriptor(orders.rowtime), interval
'2' hour))
{code}
fails with
{noformat}
The argument of DESCRIPTOR must be an identifier
{noformat}
{{SqlValidatorTest#testDescriptor}} expects exactly this message for this
query. {{orders.rowtime}} is an identifier, though a compound one, so the
message names a rule the input already satisfies. The check that raises it,
added in CALCITE-7377, rejects any operand for which
{{SqlIdentifier.isSimple()}} is false.
Seen on main at ce51f0e527 (1.43.0-SNAPSHOT), and in 1.42.0.
*Expected:* the message names the actual rule, for example "The argument of
DESCRIPTOR must be a simple identifier". Other messages for the same rule in
{{CalciteResource.properties}} use that wording: "Table or column alias must be
a simple identifier" and "Window name must be a simple identifier". SQL:2016
8.15 defines the descriptor column list as a list of {{<column name>}}.
The tests and Javadoc from CALCITE-7377 have gaps that a fix here could close
too:
* {{SqlSessionTableFunction.checkOperandTypes}} calls {{validateColumnNames}}
on its own for the key descriptor, and {{testSessionTableFunction}} has no case
for an invalid key, such as {{session(table orders, descriptor(rowtime),
descriptor(productid, orders.rowtime), interval '1' hour)}}.
* Every new case has the invalid element alone in the descriptor; none has it
after a valid element.
* The HOP case {{descriptor(1 + 2)}} goes through the same
{{checkTableAndDescriptorOperands(callBinding, 1)}} call as the TUMBLE case
{{descriptor(1+2)}}.
* The Javadoc of {{SqlWindowTableFunction.checkTableAndDescriptorOperands}}
says it throws "if any columns are not found"; it now also throws for an
operand that is not a simple identifier.
If CALCITE-7890 moves the check into {{SqlDescriptorOperator}}, the message
moves with it.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)