[
https://issues.apache.org/jira/browse/CALCITE-4293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17207705#comment-17207705
]
Alessandro Solimando commented on CALCITE-4293:
-----------------------------------------------
Looking at
[SqlItemOperator#104|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java],
ITEM operator supports ARRAY<INTEGER>, MAP<STRING> and ROW<CHAR>.
I have tried to comment the ROW case, and it breaks the following tests:
* SqlToRelConverterExtendedTest. testArrayElementDoublyNestedPrimitive()
* SqlToRelConverterExtendedTest. testArrayElementDoublyNestedStruct()
* SqlToRelConverterExtendedTest. testArrayElementNestedPrimitive()
* SqlToRelConverterExtendedTest. testArrayElementThreeTimesNestedStruct()
* SqlToRelConverterExtendedTest. testNestedPrimitiveFieldAccess()
* SqlToRelConverterExtendedTest. testNestedStructFieldAccess()
* SqlToRelConverterExtendedTest. testNestedStructPrimitiveFieldAccess()
* SqlToRelConverterTest. testArrayElementDoublyNestedPrimitive()
* SqlToRelConverterTest. testArrayElementDoublyNestedStruct()
* SqlToRelConverterTest. testArrayElementNestedPrimitive()
* SqlToRelConverterTest. testArrayElementThreeTimesNestedStruct()
* SqlToRelConverterTest. testNestedPrimitiveFieldAccess()
* SqlToRelConverterTest. testNestedStructFieldAccess()
* SqlToRelConverterTest. testNestedStructPrimitiveFieldAccess()
* SqlValidatorTest. testAccessingNestedFieldsOfNullableRecord()
I checked some of them, it appears to me that they are relying explicitly on
ITEM being applicable to ROW/STRUCT collections. This supports the validity of
applying ITEM to ROW/STRUCT collections.
However, the current ITEM operator signature
([SqlItemOperator#116|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java#L116])
contradicts that:
{code:java}
@Override public String getAllowedSignatures(String name) {
return "<ARRAY>[<INTEGER>]\n"
+ "<MAP>[<VALUE>]";
}
{code}
If it is indeed legal to apply the ITEM operator to a ROW/STRUCT collection,
then:
# _structAccess_ function
([SqlFunctions.java#L2939)|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L2939]
should be called from _item_ function
([SqlFunctions.java#L2939|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L2939]),
in the same way _mapItem_ and _arrayItem_ functions __ already are;
# The signature of ITEM operator should be updated (it's already not matching
the current type checking anyway) as follows
"<ARRAY>[<INTEGER>]\n<MAP>[<VALUE>]\n<ROW>[<VALUE>]".
Another discrepancy is that, _structAccess_ contemplates, as "index" type, both
STRING and INTEGER, while the type checker only allows for STRING when the ITEM
is applied to ROW/STRUCT.
I tried to look ITEM operator up into the SQL standard without much luck.
If you agree, I'd open a ticket for ITEM operator over ROW/STRUCT, then maybe
re-evaluate the status of the current one.
What do you think?
> cassandra adapter returns null when selecting non-null tuple elements
> ---------------------------------------------------------------------
>
> Key: CALCITE-4293
> URL: https://issues.apache.org/jira/browse/CALCITE-4293
> Project: Calcite
> Issue Type: Bug
> Components: cassandra-adapter
> Affects Versions: 1.25.0
> Reporter: Alessandro Solimando
> Assignee: Alessandro Solimando
> Priority: Major
>
> The following test currently fails due to the _EXPR$i_ elements are null and
> don't match their actual value within the _f_tuple_ field:
> {code:java}
> @Test void testTupleInnerValues() {
> CalciteAssert.that()
> .with(DTCASSANDRA)
> .query("select x['1'], x['2'], x['3'] from "
> + "(select \"f_tuple\" from \"test_collections\") as T(x)")
> .returns("EXPR$0=3000000000"
> + "; EXPR$1=30ff87"
> + "; EXPR$2=2015-05-03 13:30:54\n");
> }{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)