[
https://issues.apache.org/jira/browse/CALCITE-4293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17206002#comment-17206002
]
Alessandro Solimando commented on CALCITE-4293:
-----------------------------------------------
It is valid in the sense that the query is parsed and executed, but the final
result is that "null" is returned as output of the ITEM operator, due to the
implementation of "item" operator is "SqlFunctions":
{code:java}
SqlFunctions.java:2511):
/** Implements the {@code [ ... ]} operator on an object whose type is not
* known until runtime.
*/ public static Object item(Object object, Object index) {
if (object instanceof Map) {
return mapItem((Map) object, index);
}
if (object instanceof List && index instanceof Number) {
return arrayItem((List) object, ((Number) index).intValue());
}
return null;
}
{code}
In my case the struct is internally represented as "Object[]" (the other
possibility I have seen is to have a Java class having the same fields as the
struct, but this would not change the result here), so none of the "if" match
and "null" is finally returned.
I am under the impression that trying to apply ITEM to anything else than ARRAY
or MAP should fail (as you seems to be expecting too).
> 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)