Xikui Wang has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2770
Change subject: [ASTERIXDB-2412][COMP] ExtractCommonExpressionsRule fix
......................................................................
[ASTERIXDB-2412][COMP] ExtractCommonExpressionsRule fix
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
ExtractCommonExpressionsRule should not be applied to JOIN by using
Cartesian Product + SELECT since it will add extract overhead. Also,
blindly adding SELECT without checking GROUP-BY and other possible OPs
in between could cause type inference error.
Change-Id: I20e1fa161c42e0494c7ca587b8bffdc80d656058
---
M
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.1.ddl.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.2.update.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.3.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.1.ddl.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.2.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.3.ddl.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/results/misc/extract_common_expr-ASTERIXDB-2412/extract_common_expr-ASTERIXDB-2412.1.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M
hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonExpressionsRule.java
10 files changed, 350 insertions(+), 32 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/70/2770/1
diff --git
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
index 92b2d6a..1e9b75e9 100644
---
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
+++
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InjectTypeCastForSwitchCaseRule.java
@@ -89,7 +89,7 @@
// Injects casts that cast types for different "THEN" and "ELSE" branches.
private boolean rewriteSwitchCase(ILogicalOperator op,
AbstractFunctionCallExpression func,
IOptimizationContext context) throws AlgebricksException {
- IVariableTypeEnvironment env =
context.getOutputTypeEnvironment(op.getInputs().get(0).getValue());
+ IVariableTypeEnvironment env = context.getOutputTypeEnvironment(op);
IAType producedType = (IAType) env.getType(func);
List<Mutable<ILogicalExpression>> argRefs = func.getArguments();
int argSize = argRefs.size();
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.1.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.1.ddl.sqlpp
new file mode 100644
index 0000000..a0fcb0a
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.1.ddl.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop dataverse Coffee if exists;
+create dataverse Coffee;
+use Coffee;
+
+
+create type CoffeeType as {
+ id: string,
+ location: point
+};
+
+create type FollowersType as {
+ user_id: string,
+ twitter_id: string,
+ followers: [string]
+};
+
+create dataset Coffee(CoffeeType)
+ primary key id;
+
+create dataset Followers(FollowersType)
+ primary key user_id;
+
+
+create type CoffeeUser as closed {
+ id: int64,
+ id_str: string
+};
+
+create type Tweet as open {
+ id: int64,
+ user: CoffeeUser,
+ timestamp_ms: string
+};
+
+create dataset Tweets (Tweet)
+primary key id;
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.2.update.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.2.update.sqlpp
new file mode 100644
index 0000000..be0c667
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.2.update.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use Coffee;
+upsert into Coffee
+([
+{"id":"001", "location":point("-117.523867, 33.85216")},
+{"id":"002", "location":point("-122.37382985, 47.67917392")},
+{"id":"003", "location":point("-122.00795969, 37.40427696")},
+{"id":"004", "location":point("-122.00794969, 37.40427596")}
+]);
+
+upsert into Followers
+([
+{"user_id":"user1@Coffee", "twitter_id": "988455822727393280",
"followers":["988455822727393281","988455822727393282", "0004", "0005", "0006",
"0007", "0008"]}
+]);
+
+upsert into Tweets([
+{ "id": 999403843673718784, "user":
+{ "id": 988455822727393280, "id_str": "988455822727393280"},
+"timestamp_ms": "1527111419014",
+ "place": { "bounding_box":
+ { "coordinates": [ [ [ -117.523867, 33.85216 ], [ -117.523867, 34.019484 ], [
-117.271365, 34.019484 ], [ -117.271365, 33.85216 ] ] ]
+ } } },
+
+ { "id": 999403845, "user":
+{ "id": 988455822727393281, "id_str": "988455822727393281"},
+"timestamp_ms": "1527111419014",
+ "place": { "bounding_box":
+ { "coordinates": [ [ [ -117.523867, 33.85216 ], [ -117.523867, 34.019484 ], [
-117.271365, 34.019484 ], [ -117.271365, 33.85216 ] ] ]
+ } } },
+
+ { "id": 999403846, "user":
+{ "id": 988455822727393282, "id_str": "988455822727393282"},
+"timestamp_ms": "1527111419014",
+ "place": { "bounding_box":
+ { "coordinates": [ [ [ -117.523867, 33.85216 ], [ -117.523867, 34.019484 ], [
-117.271365, 34.019484 ], [ -117.271365, 33.85216 ] ] ]
+ } } }
+]);
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.3.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.3.query.sqlpp
new file mode 100644
index 0000000..a394f0a
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2412/comp-ASTERIXDB-2412.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use Coffee;
+
+let result = (select * from Tweets t
+let followers = (select * from Tweets f where
spatial_intersect(create_circle(create_point(f.place.bounding_box.coordinates[0][0][0],f.place.bounding_box.coordinates[0][0][1]),5.0),
+create_circle(create_point(t.place.bounding_box.coordinates[0][0][0],t.place.bounding_box.coordinates[0][0][1]),5.0))),
+sb = (select value s.location from Coffee s where
spatial_intersect(create_circle(create_point(t.place.bounding_box.coordinates[0][0][0],t.place.bounding_box.coordinates[0][0][1]),5.0),s.location)))
+select value count(*) from result;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.1.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.1.ddl.sqlpp
new file mode 100644
index 0000000..1958cde
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.1.ddl.sqlpp
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop dataverse tpcds if exists;
+create dataverse tpcds;
+
+use tpcds;
+
+create type tpcds.customer_address_type as closed {
+ ca_address_sk : bigint,
+ ca_address_id : string,
+ ca_street_number : string?,
+ ca_street_name : string?,
+ ca_street_type : string?,
+ ca_suite_number : string?,
+ ca_city : string?,
+ ca_county : string?,
+ ca_state : string?,
+ ca_zip : string?,
+ ca_country : string?,
+ ca_gmt_offset : double?,
+ ca_location_type : string?
+ };
+
+create type tpcds.web_sales_type as
+ closed {
+ ws_sold_date_sk : bigint?,
+ ws_sold_time_sk : bigint?,
+ ws_ship_date_sk : bigint?,
+ ws_item_sk : bigint,
+ ws_bill_customer_sk : bigint?,
+ ws_bill_cdemo_sk : bigint?,
+ ws_bill_hdemo_sk : bigint?,
+ ws_bill_addr_sk : bigint?,
+ ws_ship_customer_sk : bigint?,
+ ws_ship_cdemo_sk : bigint?,
+ ws_ship_hdemo_sk : bigint?,
+ ws_ship_addr_sk : bigint?,
+ ws_web_page_sk : bigint?,
+ ws_web_site_sk : bigint?,
+ ws_ship_mode_sk : bigint?,
+ ws_warehouse_sk : bigint?,
+ ws_promo_sk : bigint?,
+ ws_order_number : bigint,
+ ws_quantity : bigint?,
+ ws_wholesale_cost : double?,
+ ws_list_price : double?,
+ ws_sales_price : double?,
+ ws_ext_discount_amt : double?,
+ ws_ext_sales_price : double?,
+ ws_ext_wholesale_cost : double?,
+ ws_ext_list_price : double?,
+ ws_ext_tax : double?,
+ ws_coupon_amt : double?,
+ ws_ext_ship_cost : double?,
+ ws_net_paid : double?,
+ ws_net_paid_inc_tax : double?,
+ ws_net_paid_inc_ship : double?,
+ ws_net_paid_inc_ship_tax : double?,
+ ws_net_profit : double?
+};
+
+create type tpcds.store_sales_type as
+ closed {
+ ss_sold_date_sk: bigint?,
+ ss_sold_time_sk: bigint?,
+ ss_item_sk: bigint,
+ ss_customer_sk: bigint?,
+ ss_cdemo_sk: bigint?,
+ ss_hdemo_sk: bigint?,
+ ss_addr_sk: bigint?,
+ ss_store_sk: bigint?,
+ ss_promo_sk: bigint?,
+ ss_ticket_number: bigint,
+ ss_quantity: bigint?,
+ ss_wholesale_cost: double?,
+ ss_list_price: double?,
+ ss_sales_price: double?,
+ ss_ext_discount_amt: double?,
+ ss_ext_sales_price: double?,
+ ss_ext_wholesale_cost: double?,
+ ss_ext_list_price: double?,
+ ss_ext_tax: double?,
+ ss_coupon_amt: double?,
+ ss_net_paid: double?,
+ ss_net_paid_inc_tax: double?,
+ ss_net_profit: double?
+};
+
+create type tpcds.date_dim_type as
+ closed {
+ d_date_sk : bigint,
+ d_date_id : string,
+ d_date : string?,
+ d_month_seq : bigint?,
+ d_week_seq : bigint?,
+ d_quarter_seq : bigint?,
+ d_year : bigint? ,
+ d_dow : bigint? ,
+ d_moy : bigint?,
+ d_dom : bigint?,
+ d_qoy : bigint?,
+ d_fy_year : bigint?,
+ d_fy_quarter_seq : bigint?,
+ d_fy_week_seq : bigint?,
+ d_day_name : string?,
+ d_quarter_name : string?,
+ d_holiday : string?,
+ d_weekend : string?,
+ d_following_holiday : string?,
+ d_first_dom : bigint?,
+ d_last_dom : bigint?,
+ d_same_day_ly : bigint?,
+ d_same_day_lq : bigint?,
+ d_current_day : string?,
+ d_current_week : string?,
+ d_current_month : string?,
+ d_current_quarter : string?,
+ d_current_year : string?
+};
+
+create dataset customer_address(customer_address_type) primary key
ca_address_sk;
+
+create dataset web_sales (web_sales_type) primary key ws_item_sk,
ws_order_number;
+
+create dataset store_sales (store_sales_type) primary key ss_item_sk,
ss_ticket_number;
+
+create dataset date_dim(date_dim_type) primary key d_date_sk;
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.2.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.2.query.sqlpp
new file mode 100644
index 0000000..b6b1e0c
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.2.query.sqlpp
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE tpcds;
+
+WITH ss AS
+ (SELECT sum(ss.ss_ext_sales_price) as store_sales
+ FROM store_sales ss),
+ ws AS
+ (SELECT sum(ws.ws_ext_sales_price) as web_sales
+ FROM web_sales ws)
+ SELECT
+ ss1.d_year
+ FROM
+ ss ss1
+ ,ss ss2
+ ,ws ws1
+ ,ws ws2
+ WHERE
+ (CASE WHEN ws1.web_sales > 0 THEN ws2.web_sales/ws1.web_sales ELSE null
END)
+ > (CASE WHEN ss1.store_sales > 0 THEN ss2.store_sales/ss1.store_sales
ELSE null END);
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.3.ddl.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.3.ddl.sqlpp
new file mode 100644
index 0000000..3f600e9
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/comp-ASTERIXDB-2415/comp-ASTERIXDB-2415.3.ddl.sqlpp
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+drop dataverse tpcds;
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/extract_common_expr-ASTERIXDB-2412/extract_common_expr-ASTERIXDB-2412.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/extract_common_expr-ASTERIXDB-2412/extract_common_expr-ASTERIXDB-2412.1.adm
new file mode 100644
index 0000000..e440e5c
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/extract_common_expr-ASTERIXDB-2412/extract_common_expr-ASTERIXDB-2412.1.adm
@@ -0,0 +1 @@
+3
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 8817bc8..f694214 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3663,6 +3663,16 @@
</test-group>
<test-group name="misc">
<test-case FilePath="misc">
+ <compilation-unit name="comp-ASTERIXDB-2415">
+ <output-dir compare="Text">query-ASTERIXDB-1671</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="misc">
+ <compilation-unit name="comp-ASTERIXDB-2412">
+ <output-dir compare="Text">comp-ASTERIXDB-2412</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="misc">
<compilation-unit name="poll-dynamic">
<output-dir compare="Text">poll-dynamic</output-dir>
</compilation-unit>
diff --git
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonExpressionsRule.java
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonExpressionsRule.java
index 87053c8..1bb6de6 100644
---
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonExpressionsRule.java
+++
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonExpressionsRule.java
@@ -75,15 +75,6 @@
* distinct ([$$5])
* assign [$$5] <- [field-access($$0, 1)]
* unnest $$0 <- [scan-dataset]
- * Example 3 - Pulling Common Expressions Above Joins (simplified)
- * Before plan:
- * assign [$$9] <- funcZ(funcY($$8))
- * join (funcX(funcY($$8)))
- * After plan:
- * assign [$$9] <- funcZ($$10))
- * select (funcX($$10))
- * assign [$$10] <- [funcY($$8)]
- * join (TRUE)
*/
public class ExtractCommonExpressionsRule implements IAlgebraicRewriteRule {
@@ -305,28 +296,9 @@
SourceLocation sourceLoc = expr.getSourceLocation();
AbstractLogicalOperator firstOp = (AbstractLogicalOperator)
exprEqClass.getFirstOperator();
Mutable<ILogicalExpression> firstExprRef =
exprEqClass.getFirstExpression();
- if (firstOp.getOperatorTag() == LogicalOperatorTag.INNERJOIN
- || firstOp.getOperatorTag() ==
LogicalOperatorTag.LEFTOUTERJOIN) {
- // Do not extract common expressions from within the same join
operator.
- if (firstOp == op) {
- return false;
- }
- AbstractBinaryJoinOperator joinOp =
(AbstractBinaryJoinOperator) firstOp;
- Mutable<ILogicalExpression> joinCond = joinOp.getCondition();
- ILogicalExpression enclosingExpr =
getEnclosingExpression(joinCond, firstExprRef.getValue());
- if (enclosingExpr == null) {
- // No viable enclosing expression that we can pull out
from the join.
- return false;
- }
- // Place a Select operator beneath op that contains the
enclosing expression.
- SelectOperator selectOp =
- new SelectOperator(new
MutableObject<ILogicalExpression>(enclosingExpr), false, null);
- selectOp.setSourceLocation(enclosingExpr.getSourceLocation());
- selectOp.getInputs().add(new
MutableObject<ILogicalOperator>(op.getInputs().get(0).getValue()));
- op.getInputs().get(0).setValue(selectOp);
- // Set firstOp to be the select below op, since we want to
assign the common subexpr there.
- firstOp = selectOp;
- } else if (firstOp.getInputs().size() > 1) {
+ // We don't consider to eliminate common exprs in join operators
by doing a cartesian production
+ // and pulling the condition in to a select. This will negatively
impact the performance.
+ if (firstOp.getInputs().size() > 1) {
// Bail for any non-join operator with multiple inputs.
return false;
}
--
To view, visit https://asterix-gerrit.ics.uci.edu/2770
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I20e1fa161c42e0494c7ca587b8bffdc80d656058
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Xikui Wang <[email protected]>