Merge lp:~mmcm/akiban-server/sql-product-map-depth into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2709
Merged at revision: 2716
Proposed branch: lp:~mmcm/akiban-server/sql-product-map-depth
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 310 lines (+214/-3)
14 files modified
src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java (+7/-3)
src/test/java/com/akiban/server/test/it/qp/Map_NestedLoopsIT.java (+44/-0)
src/test/java/com/akiban/sql/pg/PostgresServerPipelineSelectIT.java (+78/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/README.txt (+3/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/addresses.dat (+2/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/customers.dat (+3/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/items.dat (+6/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/orders.dat (+6/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/pipeline.properties (+5/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/schema.ddl (+44/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.expected (+4/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.sql (+3/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.expected (+3/-0)
src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.sql (+6/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-server/sql-product-map-depth
Reviewer Review Type Date Requested Status
Thomas Jones-Low Needs Fixing
Nathan Williams Approve
Review via email: mp+177056@code.launchpad.net

Description of the change

Fix depth setting for the left-deep Maps generated by Product.

They do not get deeper and deeper. Rather all but the first are one-deeper. This is different from the nested Maps for cross-product, which tend to be right-deep and so do get deeper.

To test this, and for the future, add a new Postgres IT that runs SQL queries with the pipeline options on.

Also add a Map IT for this kind of nesting, although it was already executing fine if the depths were consistent.

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

Looks good.

review: Approve
Revision history for this message
Thomas Jones-Low (tjoneslo) wrote :

There were 3 failures during build/test:

* job server-build failed at build number 4140: http://sneezy.softstart.com:8080/job/server-build/4140/

* view must-pass failed: server-build is yellow

* view must-pass failed: server-packages is blue_anime

review: Needs Fixing
Revision history for this message
Nathan Williams (nwilliams) wrote :

Unrelated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java'
2--- src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java 2013-07-24 23:06:43 +0000
3+++ src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java 2013-07-25 22:02:24 +0000
4@@ -1583,8 +1583,10 @@
5 for (PlanNode subplan : product.getSubplans()) {
6 if (pstream.operator != null) {
7 pushBoundRow(flattened);
8- nestedBindingsDepth++;
9- nbound++;
10+ if (nbound++ == 0) {
11+ // Only one deeper for all, since nest on the outer side.
12+ nestedBindingsDepth++;
13+ }
14 }
15 RowStream stream = assembleStream(subplan);
16 if (pstream.operator == null) {
17@@ -1615,9 +1617,11 @@
18 }
19 flattened.setRowType(pstream.rowType);
20 }
21+ if (nbound > 0) {
22+ nestedBindingsDepth--;
23+ }
24 while (nbound > 0) {
25 popBoundRow();
26- nestedBindingsDepth--;
27 nbound--;
28 }
29 return pstream;
30
31=== modified file 'src/test/java/com/akiban/server/test/it/qp/Map_NestedLoopsIT.java'
32--- src/test/java/com/akiban/server/test/it/qp/Map_NestedLoopsIT.java 2013-07-24 23:06:43 +0000
33+++ src/test/java/com/akiban/server/test/it/qp/Map_NestedLoopsIT.java 2013-07-25 22:02:24 +0000
34@@ -346,6 +346,50 @@
35 compareRows(expected, cursor(plan, queryContext, queryBindings));
36 }
37
38+ @Test
39+ public void testLeftDeepMap()
40+ {
41+ RowType intRowType = schema.newValuesType(AkType.INT);
42+ List<ExpressionGenerator> outerExprs = Arrays.asList(boundField(intRowType, 0, 0), field(intRowType, 0));
43+ Operator middle =
44+ project_Default(
45+ valuesScan_Default(
46+ bindableExpressions(intRow(intRowType, 10),
47+ intRow(intRowType, 20)),
48+ intRowType),
49+ intRowType, outerExprs);
50+ RowType outerRowType = middle.rowType();
51+ Operator outer =
52+ map_NestedLoops(
53+ valuesScan_Default(
54+ bindableExpressions(intRow(intRowType, 100),
55+ intRow(intRowType, 200)),
56+ intRowType),
57+ middle,
58+ 0, pipelineMap(), 1);
59+ List<ExpressionGenerator> innerExprs = Arrays.asList(boundField(outerRowType, 1, 0), boundField(outerRowType, 1, 1), field(intRowType, 0));
60+ Operator inner =
61+ project_Default(
62+ valuesScan_Default(
63+ bindableExpressions(intRow(intRowType, 1),
64+ intRow(intRowType, 2)),
65+ intRowType),
66+ intRowType, innerExprs);
67+ RowType innerRowType = inner.rowType();
68+ Operator plan = map_NestedLoops(outer, inner, 1, pipelineMap(), 1);
69+ RowBase[] expected = new RowBase[]{
70+ row(innerRowType, 100L, 10L, 1L),
71+ row(innerRowType, 100L, 10L, 2L),
72+ row(innerRowType, 100L, 20L, 1L),
73+ row(innerRowType, 100L, 20L, 2L),
74+ row(innerRowType, 200L, 10L, 1L),
75+ row(innerRowType, 200L, 10L, 2L),
76+ row(innerRowType, 200L, 20L, 1L),
77+ row(innerRowType, 200L, 20L, 2L),
78+ };
79+ compareRows(expected, cursor(plan, queryContext, queryBindings));
80+ }
81+
82 private Row intRow(RowType rowType, int x)
83 {
84 List<Expression> expressions;
85
86=== added file 'src/test/java/com/akiban/sql/pg/PostgresServerPipelineSelectIT.java'
87--- src/test/java/com/akiban/sql/pg/PostgresServerPipelineSelectIT.java 1970-01-01 00:00:00 +0000
88+++ src/test/java/com/akiban/sql/pg/PostgresServerPipelineSelectIT.java 2013-07-25 22:02:24 +0000
89@@ -0,0 +1,78 @@
90+/**
91+ * Copyright (C) 2009-2013 Akiban Technologies, Inc.
92+ *
93+ * This program is free software: you can redistribute it and/or modify
94+ * it under the terms of the GNU Affero General Public License as published by
95+ * the Free Software Foundation, either version 3 of the License, or
96+ * (at your option) any later version.
97+ *
98+ * This program is distributed in the hope that it will be useful,
99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
100+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101+ * GNU Affero General Public License for more details.
102+ *
103+ * You should have received a copy of the GNU Affero General Public License
104+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
105+ */
106+
107+package com.akiban.sql.pg;
108+
109+import com.akiban.sql.NamedParamsTestBase;
110+import com.akiban.sql.TestBase;
111+
112+import com.akiban.junit.NamedParameterizedRunner;
113+import com.akiban.junit.NamedParameterizedRunner.TestParameters;
114+import com.akiban.junit.Parameterization;
115+import org.junit.runner.RunWith;
116+
117+import java.io.File;
118+import java.io.FileInputStream;
119+import java.io.IOException;
120+import java.util.Collection;
121+import java.util.HashMap;
122+import java.util.Map;
123+import java.util.Properties;
124+
125+@RunWith(NamedParameterizedRunner.class)
126+public class PostgresServerPipelineSelectIT extends PostgresServerSelectIT
127+{
128+ public static final File RESOURCE_DIR =
129+ new File(PostgresServerITBase.RESOURCE_DIR, "pipeline-select");
130+
131+ @Override
132+ protected Map<String, String> startupConfigProperties() {
133+ Properties loadedProperties = new Properties();
134+ try {
135+ FileInputStream istr = new FileInputStream(new File(RESOURCE_DIR,
136+ "pipeline.properties"));
137+ loadedProperties.load(istr);
138+ istr.close();
139+ }
140+ catch (IOException ex) {
141+ throw new RuntimeException(ex);
142+ }
143+
144+ Map<String, String> properties = new HashMap<>();
145+ for (String key : loadedProperties.stringPropertyNames()) {
146+ properties.put(key, loadedProperties.getProperty(key));
147+ }
148+ return properties;
149+ }
150+
151+ @Override
152+ public void loadDatabase() throws Exception {
153+ loadDatabase(RESOURCE_DIR);
154+ }
155+
156+ @TestParameters
157+ public static Collection<Parameterization> queries() throws Exception {
158+ return NamedParamsTestBase.namedCases(TestBase.sqlAndExpectedAndParams(RESOURCE_DIR));
159+ }
160+
161+ public PostgresServerPipelineSelectIT(String caseName, String sql,
162+ String expected, String error,
163+ String[] params) {
164+ super(caseName, sql, expected, error, params);
165+ }
166+
167+}
168
169=== added directory 'src/test/resources/com/akiban/sql/pg/pipeline-select'
170=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/README.txt'
171--- src/test/resources/com/akiban/sql/pg/pipeline-select/README.txt 1970-01-01 00:00:00 +0000
172+++ src/test/resources/com/akiban/sql/pg/pipeline-select/README.txt 2013-07-25 22:02:24 +0000
173@@ -0,0 +1,3 @@
174+select-1: Index to GroupLookup
175+
176+select-3: 3-way product
177
178=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/addresses.dat'
179--- src/test/resources/com/akiban/sql/pg/pipeline-select/addresses.dat 1970-01-01 00:00:00 +0000
180+++ src/test/resources/com/akiban/sql/pg/pipeline-select/addresses.dat 2013-07-25 22:02:24 +0000
181@@ -0,0 +1,2 @@
182+101 1 MA Boston
183+201 2 NY New York
184
185=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/customers.dat'
186--- src/test/resources/com/akiban/sql/pg/pipeline-select/customers.dat 1970-01-01 00:00:00 +0000
187+++ src/test/resources/com/akiban/sql/pg/pipeline-select/customers.dat 2013-07-25 22:02:24 +0000
188@@ -0,0 +1,3 @@
189+1 Smith
190+2 Jones
191+3 Adams
192
193=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/items.dat'
194--- src/test/resources/com/akiban/sql/pg/pipeline-select/items.dat 1970-01-01 00:00:00 +0000
195+++ src/test/resources/com/akiban/sql/pg/pipeline-select/items.dat 2013-07-25 22:02:24 +0000
196@@ -0,0 +1,6 @@
197+1011 101 1234 100
198+1012 101 4567 50
199+2011 201 9876 1
200+2021 202 1234 99
201+3011 301 9876 2
202+4011 401 9999 888
203
204=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/orders.dat'
205--- src/test/resources/com/akiban/sql/pg/pipeline-select/orders.dat 1970-01-01 00:00:00 +0000
206+++ src/test/resources/com/akiban/sql/pg/pipeline-select/orders.dat 2013-07-25 22:02:24 +0000
207@@ -0,0 +1,6 @@
208+101 1 2011-03-01
209+102 1 2011-03-02
210+201 2 2011-03-03
211+202 2 2011-02-28
212+301 3 2011-03-04
213+401 4 2010-01-01
214
215=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/pipeline.properties'
216--- src/test/resources/com/akiban/sql/pg/pipeline-select/pipeline.properties 1970-01-01 00:00:00 +0000
217+++ src/test/resources/com/akiban/sql/pg/pipeline-select/pipeline.properties 2013-07-25 22:02:24 +0000
218@@ -0,0 +1,5 @@
219+akserver.pipeline.map.enabled=true
220+akserver.pipeline.indexScan.lookaheadQuantum=10
221+akserver.pipeline.groupLookup.lookaheadQuantum=10
222+akserver.pipeline.unionAll.openBoth=true
223+akserver.pipeline.selectBloomFilter.enabled=true
224
225=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/schema.ddl'
226--- src/test/resources/com/akiban/sql/pg/pipeline-select/schema.ddl 1970-01-01 00:00:00 +0000
227+++ src/test/resources/com/akiban/sql/pg/pipeline-select/schema.ddl 2013-07-25 22:02:24 +0000
228@@ -0,0 +1,44 @@
229+
230+CREATE TABLE customers
231+(
232+ cid int NOT NULL,
233+ PRIMARY KEY(cid),
234+ name varchar(32) NOT NULL
235+);
236+CREATE INDEX name ON customers(name);
237+
238+CREATE TABLE orders
239+(
240+ oid int NOT NULL,
241+ PRIMARY KEY(oid),
242+ cid int NOT NULL,
243+ order_date date NOT NULL,
244+ GROUPING FOREIGN KEY (cid) REFERENCES customers(cid)
245+);
246+CREATE INDEX cid ON orders(cid);
247+CREATE INDEX order_date ON orders(order_date);
248+
249+CREATE TABLE items
250+(
251+ iid int NOT NULL,
252+ PRIMARY KEY(iid),
253+ oid int NOT NULL,
254+ sku varchar(32) NOT NULL,
255+ quan int NOT NULL,
256+ GROUPING FOREIGN KEY (oid) REFERENCES orders(oid)
257+);
258+CREATE INDEX sku ON items(sku);
259+
260+CREATE TABLE addresses
261+(
262+ aid int NOT NULL,
263+ PRIMARY KEY(aid),
264+ cid int NOT NULL,
265+ state CHAR(2),
266+ city VARCHAR(100),
267+ GROUPING FOREIGN KEY (cid) REFERENCES customers(cid)
268+);
269+
270+CREATE INDEX cname_and_sku ON customers(customers.name, items.sku) USING LEFT JOIN;
271+CREATE INDEX sku_and_date ON customers(items.sku, orders.order_date) USING LEFT JOIN;
272+CREATE INDEX date_and_name ON customers(orders.order_date, customers.name) USING RIGHT JOIN;
273
274=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.expected'
275--- src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.expected 1970-01-01 00:00:00 +0000
276+++ src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.expected 2013-07-25 22:02:24 +0000
277@@ -0,0 +1,4 @@
278+name order_date sku quan
279+Smith 2011-03-02 null null
280+Jones 2011-03-03 9876 1
281+Adams 2011-03-04 9876 2
282
283=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.sql'
284--- src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.sql 1970-01-01 00:00:00 +0000
285+++ src/test/resources/com/akiban/sql/pg/pipeline-select/select-1.sql 2013-07-25 22:02:24 +0000
286@@ -0,0 +1,3 @@
287+SELECT name, order_date, sku, quan
288+ FROM customers INNER JOIN orders ON customers.cid = orders.cid LEFT JOIN items ON orders.oid = items.oid
289+ WHERE order_date > '2011-03-01'
290\ No newline at end of file
291
292=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.expected'
293--- src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.expected 1970-01-01 00:00:00 +0000
294+++ src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.expected 2013-07-25 22:02:24 +0000
295@@ -0,0 +1,3 @@
296+name city state order_date quan order_date sku quan
297+Smith Boston MA 2011-03-01 100 2011-03-01 4567 50
298+Jones New York NY 2011-02-28 99 2011-03-03 9876 1
299
300=== added file 'src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.sql'
301--- src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.sql 1970-01-01 00:00:00 +0000
302+++ src/test/resources/com/akiban/sql/pg/pipeline-select/select-3.sql 2013-07-25 22:02:24 +0000
303@@ -0,0 +1,6 @@
304+SELECT c.name, a.city, a.state, o1.order_date, i1.quan, o2.order_date, i2.sku, i2.quan
305+ FROM customers c
306+ INNER JOIN addresses a ON c.cid = a.cid
307+ INNER JOIN orders o1 ON c.cid = o1.cid INNER JOIN items i1 ON o1.oid = i1.oid
308+ INNER JOIN orders o2 ON c.cid = o2.cid INNER JOIN items i2 ON o2.oid = i2.oid
309+ WHERE i1.sku = '1234' AND i1.iid <> i2.iid
310\ No newline at end of file

Subscribers

People subscribed via source and target branches