[
https://issues.apache.org/jira/browse/CALCITE-2010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16375626#comment-16375626
]
zhen wang commented on CALCITE-2010:
------------------------------------
some thoughts, and need your comments [~julianhyde]
{code}
@Test public void testUnionAllValues() {
CalciteAssert.hr()
.query("select x, y from (values (1, 2)) as t(x, y)\n"
+ "union all\n"
+ "select a + b, a - b from (values (3, 4), (2, 1), (5, 6)) as u(a,
b)")
.runs();
}
{code}
the above query actually runs.
The problem:
{code}
rel#31:Subset#0.ENUMERABLE.[], best=rel#36, importance=0.9
rel#36:EnumerableValues.ENUMERABLE.[[0, 1],
[1]](type=RecordType(INTEGER X, INTEGER Y),tuples=[{ 1, 2 }]), rowcount=1.0,
cumulative cost={1.0 rows, 1.0 cpu, 0.0 io}
rel#37:EnumerableProject.ENUMERABLE.[](input=rel#31:Subset#0.ENUMERABLE.[],X=$0,Y=$1),
rowcount=1.0, cumulative cost={2.0 rows, 3.0 cpu, 0.0 io}
Set#3, type: RecordType(INTEGER EXPR$0, INTEGER EXPR$1)
rel#20:Subset#3.NONE.[0], best=null, importance=0.81
rel#19:LogicalProject.NONE.[[0]](input=rel#18:Subset#2.NONE.[],EXPR$0=+($0,
$1),EXPR$1=-($0, $1)), rowcount=2.0, cumulative cost={inf}
rel#30:Subset#3.ENUMERABLE.[0], best=null, importance=0.9
rel#34:Subset#3.ENUMERABLE.[], best=rel#33, importance=0.45
rel#33:EnumerableProject.ENUMERABLE.[](input=rel#32:Subset#2.ENUMERABLE.[],EXPR$0=+($0,
$1),EXPR$1=-($0, $1)), rowcount=2.0, cumulative cost={4.0 rows, 5.0 cpu, 0.0
io}
Set#4, type: RecordType(INTEGER X, INTEGER Y)
rel#22:Subset#4.NONE.[], best=null, importance=0.9
rel#21:LogicalUnion.NONE.[](input#0=rel#15:Subset#0.NONE.[],input#1=rel#20:Subset#3.NONE.[0],all=true),
rowcount=3.0, cumulative cost={inf}
rel#26:Subset#4.ENUMERABLE.[], best=null, importance=1.0
rel#27:AbstractConverter.ENUMERABLE.[](input=rel#22:Subset#4.NONE.[],convention=ENUMERABLE,sort=[]),
rowcount=3.0, cumulative cost={inf}
rel#28:EnumerableUnion.ENUMERABLE.[](input#0=rel#31:Subset#0.ENUMERABLE.[],input#1=rel#30:Subset#3.ENUMERABLE.[0],all=true),
rowcount=3.0, cumulative cost={inf}
{code}
you can see that the main relation #28 EnumerableUnion.ENUMERABLE contains two
inputs: #31 and #30. #31 is properly resolved. #30 is not. thus #28 as parent
can't be solved.
#30 and #34 are very similar, except for planner derived a implicit collation
on #30.
should the solution be :
1. derive a best for #30 ? since #34 has a best solution, #30 has more traits
or 2. the input of the #28 shouldn't be #30, since #34 is the untouched
version.
> Cannot plan query that is UNION ALL applied to VALUES
> -----------------------------------------------------
>
> Key: CALCITE-2010
> URL: https://issues.apache.org/jira/browse/CALCITE-2010
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Priority: Major
>
> Cannot plan query that is UNION ALL applied to VALUES. For example, in
> JdbcTest:
> {code}
> @Test public void testUnionAllValues() {
> CalciteAssert.hr()
> .query("select x, y from (values (1, 2)) as t(x, y)\n"
> + "union all\n"
> + "select a + b, a - b from (values (3, 4), (5, 6)) as u(a, b)")
> .returnsUnordered();
> }
> {code}
> gives
> {noformat}
> java.sql.SQLException: Error while executing SQL "select x, y from (values
> (1, 2)) as t(x, y)
> union all
> select a + b, a - b from (values (3, 4), (5, 6)) as u(a, b)": Node
> [rel#26:Subset#4.ENUMERABLE.[]] could not be implemented; planner state:
> Root: rel#26:Subset#4.ENUMERABLE.[]
> Original rel:
> LogicalUnion(subset=[rel#26:Subset#4.ENUMERABLE.[]], all=[true]): rowcount =
> 3.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 21
> LogicalProject(subset=[rel#17:Subset#1.NONE.[]], X=[$0], Y=[$1]): rowcount
> = 1.0, cumulative cost = {1.0 rows, 2.0 cpu, 0.0 io}, id = 16
> LogicalValues(subset=[rel#15:Subset#0.NONE.[]], tuples=[[{ 1, 2 }]]):
> rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 1
> LogicalProject(subset=[rel#20:Subset#3.NONE.[0]], EXPR$0=[+($0, $1)],
> EXPR$1=[-($0, $1)]): rowcount = 2.0, cumulative cost = {2.0 rows, 4.0 cpu,
> 0.0 io}, id = 19
> LogicalValues(subset=[rel#18:Subset#2.NONE.[]], tuples=[[{ 3, 4 }, { 5, 6
> }]]): rowcount = 2.0, cumulative cost = {2.0 rows, 1.0 cpu, 0.0 io}, id = 4
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)