This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new ed50d7f344f branch-3.0: [BugFix](Variant) limit cast elimination to
one level cast #47778 (#47954)
ed50d7f344f is described below
commit ed50d7f344fea5d8d9a0f40cd3b812ef6c5a5f0b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Feb 25 19:09:29 2025 +0800
branch-3.0: [BugFix](Variant) limit cast elimination to one level cast
#47778 (#47954)
Cherry-picked from #47778
Co-authored-by: lihangyu <[email protected]>
---
be/src/pipeline/exec/scan_operator.cpp | 6 ++++--
regression-test/data/variant_p0/rqg/rqg4.out | Bin 184 -> 199 bytes
regression-test/suites/variant_p0/rqg/rqg4.sql | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/be/src/pipeline/exec/scan_operator.cpp
b/be/src/pipeline/exec/scan_operator.cpp
index cb91682fcb1..850bb81d2c5 100644
--- a/be/src/pipeline/exec/scan_operator.cpp
+++ b/be/src/pipeline/exec/scan_operator.cpp
@@ -505,9 +505,11 @@ bool ScanLocalState<Derived>::_ignore_cast(SlotDescriptor*
slot, vectorized::VEx
if (slot->type().is_string_type() && expr->type().is_string_type()) {
return true;
}
- // Variant slot cast could be eliminated
+ // only one level cast expr could push down for variant type
+ // check if expr is cast and it's children is slot
if (slot->type().is_variant_type()) {
- return true;
+ return expr->node_type() == TExprNodeType::CAST_EXPR &&
+ expr->children().at(0)->is_slot_ref();
}
if (slot->type().is_array_type()) {
if (slot->type().children[0].type == expr->type().type) {
diff --git a/regression-test/data/variant_p0/rqg/rqg4.out
b/regression-test/data/variant_p0/rqg/rqg4.out
index ec975af29e3..aa12f478027 100644
Binary files a/regression-test/data/variant_p0/rqg/rqg4.out and
b/regression-test/data/variant_p0/rqg/rqg4.out differ
diff --git a/regression-test/suites/variant_p0/rqg/rqg4.sql
b/regression-test/suites/variant_p0/rqg/rqg4.sql
index 775bb2a576a..1f6b3820b8f 100644
--- a/regression-test/suites/variant_p0/rqg/rqg4.sql
+++ b/regression-test/suites/variant_p0/rqg/rqg4.sql
@@ -3,4 +3,5 @@ INSERT INTO
table_500_undef_partitions2_keys3_properties4_distributed_by52(pk,va
INSERT INTO
table_500_undef_partitions2_keys3_properties4_distributed_by52(pk,var) VALUES
('0','{\"col_int_undef_signed\": 6, \"col_int_undef_signed2\": 7,
\"col_date_undef_signed\": \"2023-12-17\", \"col_date_undef_signed2\":
\"2023-12-20\", \"col_varchar_10__undef_signed\": \"j\",
\"col_varchar_1024__undef_signed\": \"u\"}'),('1','{\"col_int_undef_signed\":
1, \"col_int_undef_signed2\": 3, \"col_date_undef_signed\": \"2025-02-18\",
\"col_date_undef_signed2\": \"2023-12-16\", \"col_varc [...]
SELECT COUNT() AS field1 FROM
table_500_undef_partitions2_keys3_properties4_distributed_by52 AS table1 WHERE
( CAST(table1 . var['col_date_undef_signed'] AS text) IN ( '2027-01-16',
'2023-12-15', '2023-12-15' ));
-SELECT COUNT() AS field1 FROM
table_500_undef_partitions2_keys3_properties4_distributed_by52 AS table1 WHERE
( CAST(table1 . var['col_date_undef_signed'] AS datetime) IN ( '2027-01-16',
'2023-12-15', '2023-12-15' ));
\ No newline at end of file
+SELECT COUNT() AS field1 FROM
table_500_undef_partitions2_keys3_properties4_distributed_by52 AS table1 WHERE
( CAST(table1 . var['col_date_undef_signed'] AS datetime) IN ( '2027-01-16',
'2023-12-15', '2023-12-15' ));
+with cte1 as (select 32767 AS col_alias23973 ,
CAST(var['col_largeint_undef_signed_not_null'] AS largeint) col_alias23974 ,
( CAST(var['col_smallint_undef_signed_not_null'] AS smallint) +
CAST(var['col_tinyint_undef_signed_not_null'] AS tinyint) ) AS col_alias23975
, variance_pop ( least( CAST(var['col_tinyint_undef_signed'] AS tinyint) ,
CAST(var['col_tinyint_undef_signed_not_null'] AS tinyint) ) ) AS
col_alias23976 from table_500_undef_partitions2_keys3_properties4_distributed_
[...]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]