diff --git a/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.reference b/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.reference index cf24e3861c0..e65b9b313e0 100644 --- a/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.reference +++ b/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.reference @@ -169,3 +169,63 @@ FROM default.x AS __table1 WHERE (__table1.A AND __table1.B) OR (__table1.A AND __table1.B AND __table1.C) OR (__table1.D AND __table1.E) SETTINGS optimize_extract_common_expressions = 0 873 +QUERY id: 0 + PROJECTION COLUMNS + count() UInt64 + PROJECTION + LIST id: 1, nodes: 1 + FUNCTION id: 2, function_name: count, function_type: aggregate, result_type: UInt64 + JOIN TREE + TABLE id: 3, alias: __table1, table_name: default.x + WHERE + FUNCTION id: 4, function_name: and, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 5, nodes: 2 + COLUMN id: 6, column_name: B, result_type: UInt8, source_id: 3 + FUNCTION id: 7, function_name: or, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 8, nodes: 2 + COLUMN id: 9, column_name: A, result_type: UInt8, source_id: 3 + COLUMN id: 10, column_name: C, result_type: UInt8, source_id: 3 + SETTINGS optimize_extract_common_expressions=1 + +SELECT count() AS `count()` +FROM default.x AS __table1 +WHERE __table1.B AND (__table1.A OR __table1.C) +SETTINGS optimize_extract_common_expressions = 1 +752 +QUERY id: 0 + PROJECTION COLUMNS + count() UInt64 + PROJECTION + LIST id: 1, nodes: 1 + FUNCTION id: 2, function_name: count, function_type: aggregate, result_type: UInt64 + JOIN TREE + TABLE id: 3, alias: __table1, table_name: default.x + WHERE + FUNCTION id: 4, function_name: or, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 5, nodes: 3 + FUNCTION id: 6, function_name: and, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 7, nodes: 2 + COLUMN id: 8, column_name: A, result_type: UInt8, source_id: 3 + COLUMN id: 9, column_name: B, result_type: UInt8, source_id: 3 + FUNCTION id: 10, function_name: and, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 11, nodes: 3 + COLUMN id: 8, column_name: A, result_type: UInt8, source_id: 3 + COLUMN id: 9, column_name: B, result_type: UInt8, source_id: 3 + COLUMN id: 12, column_name: C, result_type: UInt8, source_id: 3 + FUNCTION id: 13, function_name: and, function_type: ordinary, result_type: UInt8 + ARGUMENTS + LIST id: 14, nodes: 2 + COLUMN id: 9, column_name: B, result_type: UInt8, source_id: 3 + COLUMN id: 12, column_name: C, result_type: UInt8, source_id: 3 + SETTINGS optimize_extract_common_expressions=0 + +SELECT count() AS `count()` +FROM default.x AS __table1 +WHERE (__table1.A AND __table1.B) OR (__table1.A AND __table1.B AND __table1.C) OR (__table1.B AND __table1.C) +SETTINGS optimize_extract_common_expressions = 0 +752 diff --git a/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.sql b/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.sql index e1856cbd1fc..9459576e4ca 100644 --- a/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.sql +++ b/tests/queries/0_stateless/03285_analyzer_optimize_disjunctions.sql @@ -31,3 +31,9 @@ SELECT count() FROM x WHERE (A and B) or (A and B and C) or (D and E) SETTINGS o EXPLAIN QUERY TREE dump_ast = 1 SELECT count() FROM x WHERE (A and B) or (A and B and C) or (D and E) SETTINGS optimize_extract_common_expressions = 0; SELECT count() FROM x WHERE (A and B) or (A and B and C) or (D and E) SETTINGS optimize_extract_common_expressions = 0; + +EXPLAIN QUERY TREE dump_ast = 1 SELECT count() FROM x WHERE (A and B) or (A and B and C) or (B and C) SETTINGS optimize_extract_common_expressions = 1; +SELECT count() FROM x WHERE (A and B) or (A and B and C) or (B and C) SETTINGS optimize_extract_common_expressions = 1; + +EXPLAIN QUERY TREE dump_ast = 1 SELECT count() FROM x WHERE (A and B) or (A and B and C) or (B and C) SETTINGS optimize_extract_common_expressions = 0; +SELECT count() FROM x WHERE (A and B) or (A and B and C) or (B and C) SETTINGS optimize_extract_common_expressions = 0;