Uh oh!
There was an error while loading. Please reload this page.
[fix](mtmv) Disable sql_limit variable when query rewrite by materialize view - #40106
Conversation
doris-robot
commented
Aug 29, 2024
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
seawinde
commented
Aug 29, 2024
run buildall |
doris-robot
commented
Aug 29, 2024
TPC-H: Total hot run time: 38274 ms |
doris-robot
commented
Aug 29, 2024
TPC-DS: Total hot run time: 188309 ms |
doris-robot
commented
Aug 29, 2024
ClickBench: Total hot run time: 32.65 s |
seawinde
commented
Sep 2, 2024
run buildall |
doris-robot
commented
Sep 2, 2024
TPC-H: Total hot run time: 38333 ms |
doris-robot
commented
Sep 2, 2024
TPC-DS: Total hot run time: 194014 ms |
doris-robot
commented
Sep 2, 2024
ClickBench: Total hot run time: 31.76 s |
seawinde
commented
Sep 2, 2024
run buildall |
doris-robot
commented
Sep 2, 2024
TPC-H: Total hot run time: 37721 ms |
doris-robot
commented
Sep 2, 2024
TPC-DS: Total hot run time: 193727 ms |
doris-robot
commented
Sep 2, 2024
ClickBench: Total hot run time: 32.09 s |
6e7ffe0 to
6703adaCompareseawinde
commented
Sep 3, 2024
run buildall |
doris-robot
commented
Sep 3, 2024
TPC-H: Total hot run time: 38279 ms |
doris-robot
commented
Sep 3, 2024
TPC-DS: Total hot run time: 187877 ms |
doris-robot
commented
Sep 3, 2024
ClickBench: Total hot run time: 31.86 s |
6703ada to
e4abc5fCompareseawinde
commented
Sep 4, 2024
run buildall |
| cascadesContext.getStatementContext(), rewrittenPlan, | ||
| cascadesContext.getCurrentJobContext().getRequiredProperties()); | ||
| rewrittenPlan = planRewriter.apply(rewrittenPlanContext); | ||
| // Tmp old disable rule variable |
There was a problem hiding this comment.
set disable rules here, not everywhere
doris-robot
commented
Sep 4, 2024
TPC-H: Total hot run time: 37746 ms |
doris-robot
commented
Sep 4, 2024
TPC-DS: Total hot run time: 193399 ms |
doris-robot
commented
Sep 4, 2024
ClickBench: Total hot run time: 33.07 s |
seawinde
commented
Sep 4, 2024
run buildall |
doris-robot
commented
Sep 4, 2024
TPC-H: Total hot run time: 38420 ms |
doris-robot
commented
Sep 4, 2024
TPC-DS: Total hot run time: 186529 ms |
doris-robot
commented
Sep 4, 2024
ClickBench: Total hot run time: 32.04 s |
seawinde
commented
Sep 5, 2024
run buildall |
doris-robot
commented
Sep 5, 2024
TPC-H: Total hot run time: 38262 ms |
seawinde
commented
Oct 8, 2024
run buildall |
seawinde
commented
Oct 8, 2024
run buildall |
| ctx.setThreadLocalInfo(); | ||
| ctx.getSessionVariable().allowModifyMaterializedViewData = true; | ||
| // Disable add default limit rule to avoid refresh data wrong | ||
| ctx.getSessionVariable().setDisableNereidsRules( |
There was a problem hiding this comment.
If the default values are changed in the future, there may be issues here. Can we use an additional method
There was a problem hiding this comment.
the default value of disableNereidsRules session should always be empty ''
PR approved by at least one committer and no changes requested. |
…ize view (apache#40106) In BI or some other SQL client,it will set `sql_select_limit` or `default_order_by_limit` session variables automatically. This will make mistake when query rewrite by materialized view, Because after query rewrite by materialized view, the rewritten plan would be optimized by rules again which should add limit on SQL. This pr fix this.
…ize view (apache#40106) In BI or some other SQL client,it will set `sql_select_limit` or `default_order_by_limit` session variables automatically. This will make mistake when query rewrite by materialized view, Because after query rewrite by materialized view, the rewritten plan would be optimized by rules again which should add limit on SQL. This pr fix this.
…ize view (apache#40106) In BI or some other SQL client,it will set `sql_select_limit` or `default_order_by_limit` session variables automatically. This will make mistake when query rewrite by materialized view, Because after query rewrite by materialized view, the rewritten plan would be optimized by rules again which should add limit on SQL. This pr fix this.
…s variant and log more detailed info for troubleshoot a problem (#59933) Fix query err when calc mv fd by catch it and log more detailed info for troubleshoot a problem 1. originOutputs.size() should equlas targetOutputs.size(), if not would throw exception, this would cause query err, should log err log and not cause query err 2. current log could not find the root cause, so add detail log 3. fix the problem by mapping the slot full path name between scan mv output and mv sql plan output for example as following ```sql CREATE TABLE fact_var ( k INT, v VARIANT ) ENGINE=OLAP DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); INSERT INTO fact_var VALUES (1, '{"a":1,"b":{"c":10,"d":20}}'), (2, '{"a":2,"b":{"c":30}}'); CREATE MATERIALIZED VIEW mv_var BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS SELECT k, v FROM fact_var; ``` if run query as fllowing, mv_var sacn would return k, v, v['a'] but mv_var def plan sql, would return k, v, the size is different but also can work after the fix ```sql SELECT v['a'] AS c_val FROM mv_var; ``` Related PR: #40106
…s variant and log more detailed info for troubleshoot a problem (#59933) Fix query err when calc mv fd by catch it and log more detailed info for troubleshoot a problem 1. originOutputs.size() should equlas targetOutputs.size(), if not would throw exception, this would cause query err, should log err log and not cause query err 2. current log could not find the root cause, so add detail log 3. fix the problem by mapping the slot full path name between scan mv output and mv sql plan output for example as following ```sql CREATE TABLE fact_var ( k INT, v VARIANT ) ENGINE=OLAP DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); INSERT INTO fact_var VALUES (1, '{"a":1,"b":{"c":10,"d":20}}'), (2, '{"a":2,"b":{"c":30}}'); CREATE MATERIALIZED VIEW mv_var BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS SELECT k, v FROM fact_var; ``` if run query as fllowing, mv_var sacn would return k, v, v['a'] but mv_var def plan sql, would return k, v, the size is different but also can work after the fix ```sql SELECT v['a'] AS c_val FROM mv_var; ``` Related PR: #40106
…s variant and log more detailed info for troubleshoot a problem (#59933) Fix query err when calc mv fd by catch it and log more detailed info for troubleshoot a problem 1. originOutputs.size() should equlas targetOutputs.size(), if not would throw exception, this would cause query err, should log err log and not cause query err 2. current log could not find the root cause, so add detail log 3. fix the problem by mapping the slot full path name between scan mv output and mv sql plan output for example as following ```sql CREATE TABLE fact_var ( k INT, v VARIANT ) ENGINE=OLAP DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); INSERT INTO fact_var VALUES (1, '{"a":1,"b":{"c":10,"d":20}}'), (2, '{"a":2,"b":{"c":30}}'); CREATE MATERIALIZED VIEW mv_var BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS SELECT k, v FROM fact_var; ``` if run query as fllowing, mv_var sacn would return k, v, v['a'] but mv_var def plan sql, would return k, v, the size is different but also can work after the fix ```sql SELECT v['a'] AS c_val FROM mv_var; ``` Related PR: #40106
…s variant and log more detailed info for troubleshoot a problem (apache#59933) Fix query err when calc mv fd by catch it and log more detailed info for troubleshoot a problem 1. originOutputs.size() should equlas targetOutputs.size(), if not would throw exception, this would cause query err, should log err log and not cause query err 2. current log could not find the root cause, so add detail log 3. fix the problem by mapping the slot full path name between scan mv output and mv sql plan output for example as following ```sql CREATE TABLE fact_var ( k INT, v VARIANT ) ENGINE=OLAP DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); INSERT INTO fact_var VALUES (1, '{"a":1,"b":{"c":10,"d":20}}'), (2, '{"a":2,"b":{"c":30}}'); CREATE MATERIALIZED VIEW mv_var BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS SELECT k, v FROM fact_var; ``` if run query as fllowing, mv_var sacn would return k, v, v['a'] but mv_var def plan sql, would return k, v, the size is different but also can work after the fix ```sql SELECT v['a'] AS c_val FROM mv_var; ``` Related PR: apache#40106
…ize view (apache#40106) In BI or some other SQL client,it will set `sql_select_limit` or `default_order_by_limit` session variables automatically. This will make mistake when query rewrite by materialized view, Because after query rewrite by materialized view, the rewritten plan would be optimized by rules again which should add limit on SQL. This pr fix this.
Proposed changes
In BI or some other SQL client,it will set
sql_select_limitordefault_order_by_limitsession variables automatically.This will make mistake when query rewrite by materialized view, Because after query rewrite by materialized view, the rewritten plan would be optimized by rules again which should add limit on SQL.
This pr fix this.