Hi! I am working on https://issues.apache.org/jira/browse/CALCITE-5126. When I was writing tests for this task I faced with issue that reproducible in main branch as well.
I tried to execute the following query using unnest.iq file SELECT ARRAY(SELECT * FROM UNNEST(s.x) y) FROM (SELECT ARRAY[1,2,3] as x) s; Calcite generated the following plan: EnumerableProject(EXPR$0=[$1]): rowcount = 1.0, cumulative cost = {14.0 rows, 12.0 cpu, 0.0 io}, id = 98 EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}]): rowcount = 1.0, cumulative cost = {13.0 rows, 11.0 cpu, 0.0 io}, id = 97 EnumerableValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 79 EnumerableCollect(field=[x]): rowcount = 1.0, cumulative cost = {5.0 rows, 5.0 cpu, 0.0 io}, id = 96 EnumerableProject(EXPR$0=[+($0, 1)]): rowcount = 1.0, cumulative cost = {4.0 rows, 4.0 cpu, 0.0 io}, id = 95 EnumerableUncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 94 EnumerableProject(X=[$cor0.X]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 93 EnumerableValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 79 It is a completely wrong plan. It does not use ARRAY[1,2,3] at all and code fails with error: Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.util.List (java.lang.Integer and java.util.List are in module java.base of loader 'bootstrap') Maybe someone knows how to fastly fix this?