You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2019/10/16 21:31:00 UTC
[jira] [Commented] (CALCITE-3407) Implement Minus and Intersect
relational operators in the interpreter
[ https://issues.apache.org/jira/browse/CALCITE-3407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16953207#comment-16953207 ]
Julian Hyde commented on CALCITE-3407:
--------------------------------------
Reviewing now.
> Implement Minus and Intersect relational operators in the interpreter
> ---------------------------------------------------------------------
>
> Key: CALCITE-3407
> URL: https://issues.apache.org/jira/browse/CALCITE-3407
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Wang Yanlin
> Assignee: Julian Hyde
> Priority: Major
> Labels: pull-request-available
> Time Spent: 4h 10m
> Remaining Estimate: 0h
>
> Currently, for SetOp, only `union` is supported by Interpreter
> add the test cases in InterpreterTest, and run, they will fail by throwing exception
> {code:java}
> @Test public void testInterpretIntersect() throws Exception {
> final String sql = "select * from\n"
> + "(select x, y from (values (1, 'a'), (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y))\n"
> + "intersect\n"
> + "(select x, y from (values (1, 'a'), (2, 'c'), (4, 'x')) as t2(x, y))\n";
> SqlNode validate = planner.validate(planner.parse(sql));
> RelNode convert = planner.rel(validate).rel;
> final Interpreter interpreter = new Interpreter(dataContext, convert);
> assertRows(interpreter, "[1, a]");
> }
> @Test public void testInterpretIntersectAll() throws Exception {
> final String sql = "select * from\n"
> + "(select x, y from (values (1, 'a'), (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y))\n"
> + "intersect all\n"
> + "(select x, y from (values (1, 'a'), (2, 'c'), (4, 'x')) as t2(x, y))\n";
> SqlNode validate = planner.validate(planner.parse(sql));
> RelNode convert = planner.rel(validate).rel;
> final Interpreter interpreter = new Interpreter(dataContext, convert);
> assertRows(interpreter, "[1, a]", "[1, a]");
> }
> @Test public void testInterpretMinus() throws Exception {
> final String sql = "select * from\n"
> + "(select x, y from (values (1, 'a'), (2, 'b'), (2, 'b'), (3, 'c')) as t(x, y))\n"
> + "except\n"
> + "(select x, y from (values (1, 'a'), (2, 'c'), (4, 'x')) as t2(x, y))\n";
> SqlNode validate = planner.validate(planner.parse(sql));
> RelNode convert = planner.rel(validate).rel;
> final Interpreter interpreter = new Interpreter(dataContext, convert);
> assertRows(interpreter, "[2, b]", "[3, c]");
> }
> @Test public void testInterpretMinusAll() throws Exception {
> final String sql = "select * from\n"
> + "(select x, y from (values (1, 'a'), (2, 'b'), (2, 'b'), (3, 'c')) as t(x, y))\n"
> + "except all\n"
> + "(select x, y from (values (1, 'a'), (2, 'c'), (4, 'x')) as t2(x, y))\n";
> SqlNode validate = planner.validate(planner.parse(sql));
> RelNode convert = planner.rel(validate).rel;
> final Interpreter interpreter = new Interpreter(dataContext, convert);
> assertRows(interpreter, "[2, b]", "[2, b]", "[3, c]");
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)