Merge lp:~mmcm/akiban-server/sql-in-subquery-wo-project into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2732
Merged at revision: 2732
Proposed branch: lp:~mmcm/akiban-server/sql-in-subquery-wo-project
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 57 lines (+26/-0)
4 files modified
src/main/java/com/akiban/sql/optimizer/rule/ASTStatementLoader.java (+13/-0)
src/test/resources/com/akiban/sql/optimizer/rule/parse/README.txt (+2/-0)
src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.expected (+9/-0)
src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.sql (+2/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-server/sql-in-subquery-wo-project
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+179053@code.launchpad.net

Description of the change

Handle subquery predicates with VALUES.

IN (1,2) is a special kind of node.
IN (SELECT x FROM ...) has a Project which is used to extract the comparison operand for the semi-join.
IN (VALUES 1,2) is somewhere in between. The Project isn't there, but enough information is to form the identical plan to the first case. Add that.

See new test and note that the expected result is identical to in-l3.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

Simple enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/main/java/com/akiban/sql/optimizer/rule/ASTStatementLoader.java'
--- src/main/java/com/akiban/sql/optimizer/rule/ASTStatementLoader.java 2013-07-31 20:40:42 +0000
+++ src/main/java/com/akiban/sql/optimizer/rule/ASTStatementLoader.java 2013-08-07 21:31:27 +0000
@@ -926,6 +926,19 @@
926 plan = next;926 plan = next;
927 }927 }
928 }928 }
929 if ((operands == null) &&
930 (subquery instanceof ColumnSource) &&
931 (subquery instanceof TypedPlan)) {
932 int nfields = ((TypedPlan)subquery).nFields();
933 if (!multipleOperands && (nfields != 1))
934 throw new UnsupportedSQLException("Subquery must have exactly one column", subqueryNode);
935 operands = new ArrayList<>(nfields);
936 for (int i = 0; i < nfields; i++) {
937 operands.add(new ColumnExpression(((ColumnSource)subquery), i, null, null));
938 }
939 if (nfields > 0)
940 operand = operands.get(0);
941 }
929 ConditionExpression condition;942 ConditionExpression condition;
930 if (needOperand) {943 if (needOperand) {
931 assert (operand != null);944 assert (operand != null);
932945
=== modified file 'src/test/resources/com/akiban/sql/optimizer/rule/parse/README.txt'
--- src/test/resources/com/akiban/sql/optimizer/rule/parse/README.txt 2013-07-31 20:41:01 +0000
+++ src/test/resources/com/akiban/sql/optimizer/rule/parse/README.txt 2013-08-07 21:31:27 +0000
@@ -76,6 +76,8 @@
7676
77in-4: IN with row value subquery77in-4: IN with row value subquery
7878
79in-5: IN with VALUES (explicitly as subquery)
80
79insert-1: from VALUES81insert-1: from VALUES
8082
81insert-2: from SELECT83insert-2: from SELECT
8284
=== added file 'src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.expected'
--- src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.expected 1970-01-01 00:00:00 +0000
+++ src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.expected 2013-08-07 21:31:27 +0000
@@ -0,0 +1,9 @@
1SelectQuery@6e92b1a1
2 ResultSet@68c0890f[cid, name]
3 Project@38666d83[customers.cid, customers.name]
4 Select@6f7918f0[ANY(Subquery@40b86944)]
5 TableSource@47f08ed8(customers)
6
7Subquery@40b86944
8 Project@3ab28980[customers.name == VALUES[0]]
9 ExpressionsSource@2322bce([[Smith], [Jones], [Adams]])
010
=== added file 'src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.sql'
--- src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.sql 1970-01-01 00:00:00 +0000
+++ src/test/resources/com/akiban/sql/optimizer/rule/parse/in-5.sql 2013-08-07 21:31:27 +0000
@@ -0,0 +1,2 @@
1SELECT * FROM customers
2 WHERE name IN (VALUES('Smith'), ('Jones'), ('Adams'))

Subscribers

People subscribed via source and target branches