Skip to content

Commit

Permalink
[enhance](variant) throw exception when field type is not supported i…
Browse files Browse the repository at this point in the history
…n cast elimation (apache#40388)
  • Loading branch information
eldenmoon committed Sep 5, 2024
1 parent c6771da commit b9f5133
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/olap/tablet_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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"
Expand Down Expand Up @@ -273,6 +274,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;
}
Expand Down
5 changes: 5 additions & 0 deletions regression-test/suites/variant_p0/load.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ suite("regression_test_variant", "p0"){
exception("errCode = 2, detailMessage = Variant type should not be used in key")
}

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
}
Expand Down

0 comments on commit b9f5133

Please sign in to comment.