This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 7f3681b3d7b branch-2.1: [BugFix](Variant) limit cast elimination to 
one level cast #47778 (#47955)
7f3681b3d7b is described below

commit 7f3681b3d7b4ee9d4990c665cc5a7bb34a2b8a51
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Feb 19 09:30:46 2025 +0800

    branch-2.1: [BugFix](Variant) limit cast elimination to one level cast 
#47778 (#47955)
    
    Cherry-picked from #47778
    
    Co-authored-by: lihangyu <lihan...@selectdb.com>
---
 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 b8464e3fd48..591ea01dfb9 100644
--- a/be/src/pipeline/exec/scan_operator.cpp
+++ b/be/src/pipeline/exec/scan_operator.cpp
@@ -550,9 +550,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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to