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

eldenmoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a7b67ac7eeb [enhance](variant) throw exception when field type is not 
supported in cast elimation (#40388)
a7b67ac7eeb is described below

commit a7b67ac7eeb3aa1dac68b04c2ab7687ba847c96f
Author: lihangyu <[email protected]>
AuthorDate: Thu Sep 5 21:26:17 2024 +0800

    [enhance](variant) throw exception when field type is not supported in cast 
elimation (#40388)
---
 be/src/olap/tablet_reader.cpp                 | 5 +++++
 regression-test/suites/variant_p0/load.groovy | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/be/src/olap/tablet_reader.cpp b/be/src/olap/tablet_reader.cpp
index 5966feeaaf2..dcdd8819e3d 100644
--- a/be/src/olap/tablet_reader.cpp
+++ b/be/src/olap/tablet_reader.cpp
@@ -31,6 +31,7 @@
 
 #include "common/compiler_util.h" // IWYU pragma: keep
 #include "common/config.h"
+#include "common/exception.h"
 #include "common/logging.h"
 #include "common/status.h"
 #include "exprs/bitmapfilter_predicate.h"
@@ -270,6 +271,10 @@ TabletColumn TabletReader::materialize_column(const 
TabletColumn& orig) {
     TabletColumn column_with_cast_type = orig;
     auto cast_type = 
_reader_context.target_cast_type_for_variants.at(orig.name());
     FieldType filed_type = 
TabletColumn::get_field_type_by_type(cast_type.type);
+    if (filed_type == FieldType::OLAP_FIELD_TYPE_UNKNOWN) {
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Invalid type for 
variant column: {}",
+                               cast_type.type);
+    }
     column_with_cast_type.set_type(filed_type);
     return column_with_cast_type;
 }
diff --git a/regression-test/suites/variant_p0/load.groovy 
b/regression-test/suites/variant_p0/load.groovy
index 967ff63f0ba..65a5a838c50 100644
--- a/regression-test/suites/variant_p0/load.groovy
+++ b/regression-test/suites/variant_p0/load.groovy
@@ -441,6 +441,11 @@ suite("regression_test_variant", "p0"){
         sql """insert into var_as_key values(2, '{"b" : 11}')"""
         qt_sql "select * from var_as_key order by k"
 
+        test {
+            sql """select * from ghdata where cast(v['actor']['url'] as ipv4) 
= '127.0.0.1'""" 
+            exception("Invalid type for variant column: 36")
+        }
+
     } finally {
         // reset flags
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to