mihaibudiu commented on code in PR #3423:
URL: https://github.com/apache/calcite/pull/3423#discussion_r1326338577
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java:
##########
@@ -78,7 +78,13 @@ public SqlItemOperator(String name,
SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
call.operand(0).unparse(writer, leftPrec, 0);
final SqlWriter.Frame frame = writer.startList("[", "]");
- call.operand(1).unparse(writer, 0, 0);
+ if (offset == 0) {
Review Comment:
In fact, Calcite currently treats a simple array index as a SAFE_ORDINAL
index, as the comment on SqlOperator ITEM says:
```
* <p>The SQL standard calls the ARRAY variant a
* <array element reference>. Index is 1-based. The standard says
* to raise "data exception - array element error" but we currently return
* null.
public static final SqlOperator ITEM =
new SqlItemOperator("ITEM", OperandTypes.ARRAY_OR_MAP, 1, true);
```
The last `true` argument is for the `safe` parameter.
If we take this approach, a raw index is unparsed as a SAFE_ORDINAL,
reflecting the implementation semantics.
If you want to preserve the original syntax we need to carry additional
information in the SqlItemOperator.
What is the right solution?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]