mihaibudiu commented on code in PR #4587: URL: https://github.com/apache/calcite/pull/4587#discussion_r2446189245
########## core/src/test/resources/sql/hep.iq: ########## @@ -0,0 +1,114 @@ +# hep.iq - hep tests can customizable optimization rules for hep planner +# +# 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. +# + +# This documents the required format for .iq files containing hep planner rule configurations +# +# SYNTAX: +# --------------- +# !set hep-rules " +# +CoreRules.RULE_NAME1, +# -CoreRules.RULE_NAME2, +# +EnumerableRules.ENUMERABLE_RULE_NAME" +# +# FORMAT RULES: +# ------------- +# 1. Must begin with: !set hep-rules " (double quote) +# 2. Each rule must be on its own line. All lines except last must end with comma. +# The last rule line must close with " (double quote) on final line +# 3. Rules must start with - (remove) or + (add) +# 4. Rule prefix can be: +# - CoreRules.RULE_NAME -> added/removed from hep program +# - EnumerableRules.RULE_NAME -> added/removed from volcano program +# - RULE_NAME (no prefix) -> treated as CoreRules, added/removed from hep program +# 5. Duplicate operations on the same rule: last operation wins +# Example: "+Rule1,+Rule1,-Rule1" results in rule being removed +# 6. Execution order: +# [HEP Program] (HepPlanner, configurable rules) +# ↓ +# [Volcano Program] (VolcanoPlanner, configurable rules) +# ↓ +# [Calc Program] (HepPlanner, fixed rules) Review Comment: can you add a few words about this program? since you are turning this into a file for documentation, maybe you can also point to the way you configure the volcano rules. ########## core/src/test/resources/sql/hep.iq: ########## @@ -0,0 +1,114 @@ +# hep.iq - hep tests can customizable optimization rules for hep planner +# +# 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. +# + +# This documents the required format for .iq files containing hep planner rule configurations +# +# SYNTAX: +# --------------- +# !set hep-rules " +# +CoreRules.RULE_NAME1, +# -CoreRules.RULE_NAME2, +# +EnumerableRules.ENUMERABLE_RULE_NAME" +# +# FORMAT RULES: +# ------------- +# 1. Must begin with: !set hep-rules " (double quote) +# 2. Each rule must be on its own line. All lines except last must end with comma. +# The last rule line must close with " (double quote) on final line +# 3. Rules must start with - (remove) or + (add) +# 4. Rule prefix can be: +# - CoreRules.RULE_NAME -> added/removed from hep program +# - EnumerableRules.RULE_NAME -> added/removed from volcano program +# - RULE_NAME (no prefix) -> treated as CoreRules, added/removed from hep program +# 5. Duplicate operations on the same rule: last operation wins +# Example: "+Rule1,+Rule1,-Rule1" results in rule being removed +# 6. Execution order: +# [HEP Program] (HepPlanner, configurable rules) +# ↓ +# [Volcano Program] (VolcanoPlanner, configurable rules) +# ↓ +# [Calc Program] (HepPlanner, fixed rules) + +!use scott +!set outputformat mysql + +# The hep-rules test is functioning correctly. +!set hep-rules " ++CoreRules.PROJECT_FILTER_TRANSPOSE, ++CoreRules.UNION_FILTER_TO_FILTER" + +SELECT mgr, comm FROM emp WHERE mgr = 12 +UNION +SELECT mgr, comm FROM emp WHERE comm > 5; ++------+---------+ +| MGR | COMM | ++------+---------+ +| 7698 | 1400.00 | +| 7698 | 300.00 | +| 7698 | 500.00 | ++------+---------+ +(3 rows) + +!ok +EnumerableAggregate(group=[{0, 1}]) + EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t3):INTEGER], expr#9=[12], expr#10=[=($t8, $t9)], expr#11=[CAST($t6):DECIMAL(12, 2)], expr#12=[5.00:DECIMAL(12, 2)], expr#13=[>($t11, $t12)], expr#14=[OR($t10, $t13)], MGR=[$t3], COMM=[$t6], $condition=[$t14]) + EnumerableTableScan(table=[[scott, EMP]]) +!plan +!set hep-rules original + +# Testing with the planner-rules shows that due to cost-based selection issues, +# the planner fails to choose a plan that includes the Aggregate operator. +!set planner-rules " ++CoreRules.PROJECT_FILTER_TRANSPOSE, ++CoreRules.UNION_FILTER_TO_FILTER" + +SELECT mgr, comm FROM emp WHERE mgr = 12 +UNION +SELECT mgr, comm FROM emp WHERE comm > 5; ++------+---------+ +| MGR | COMM | ++------+---------+ +| 7698 | 1400.00 | +| 7698 | 300.00 | +| 7698 | 500.00 | ++------+---------+ +(3 rows) + +!ok +EnumerableUnion(all=[false]) + EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t3):INTEGER], expr#9=[12], expr#10=[=($t8, $t9)], MGR=[$t3], COMM=[$t6], $condition=[$t10]) + EnumerableTableScan(table=[[scott, EMP]]) + EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t6):DECIMAL(12, 2)], expr#9=[5.00:DECIMAL(12, 2)], expr#10=[>($t8, $t9)], MGR=[$t3], COMM=[$t6], $condition=[$t10]) + EnumerableTableScan(table=[[scott, EMP]]) +!plan +!set planner-rules original + +# The hep-rules test validates support for modifying EnumerableRules. Review Comment: The -> This? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
