Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions be/src/exec/olap_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ inline SQLFilterOp to_olap_filter_type(TExprOpcode::type type, bool opposite) {
return FILTER_IN;
}

inline SQLFilterOp to_olap_filter_type(const std::string& function_name, bool opposite) {
inline SQLFilterOp to_olap_filter_type(const std::string& function_name) {
if (function_name == "lt") {
return opposite ? FILTER_LARGER : FILTER_LESS;
return FILTER_LESS;
} else if (function_name == "gt") {
return opposite ? FILTER_LESS : FILTER_LARGER;
return FILTER_LARGER;
} else if (function_name == "le") {
return opposite ? FILTER_LARGER_OR_EQUAL : FILTER_LESS_OR_EQUAL;
return FILTER_LESS_OR_EQUAL;
} else if (function_name == "ge") {
return opposite ? FILTER_LESS_OR_EQUAL : FILTER_LARGER_OR_EQUAL;
return FILTER_LARGER_OR_EQUAL;
} else if (function_name == "eq") {
return opposite ? FILTER_NOT_IN : FILTER_IN;
return FILTER_IN;
} else if (function_name == "ne") {
return opposite ? FILTER_IN : FILTER_NOT_IN;
return FILTER_NOT_IN;
} else if (function_name == "in") {
return opposite ? FILTER_NOT_IN : FILTER_IN;
return FILTER_IN;
} else if (function_name == "not_in") {
return opposite ? FILTER_IN : FILTER_NOT_IN;
return FILTER_NOT_IN;
} else {
DCHECK(false) << "Function Name: " << function_name;
return FILTER_IN;
Expand Down
10 changes: 6 additions & 4 deletions be/src/exprs/create_predicate_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ std::shared_ptr<ColumnPredicate> create_olap_column_predicate(
const TabletColumn* column, bool) {
// currently only support like predicate
if constexpr (PT == TYPE_CHAR) {
return LikeColumnPredicate<TYPE_CHAR>::create_shared(
filter->_opposite, column_id, filter->_fn_ctx, filter->_string_param);
return LikeColumnPredicate<TYPE_CHAR>::create_shared(filter->_opposite, column_id,
column->name(), filter->_fn_ctx,
filter->_string_param);
} else if constexpr (PT == TYPE_VARCHAR || PT == TYPE_STRING) {
return LikeColumnPredicate<TYPE_STRING>::create_shared(
filter->_opposite, column_id, filter->_fn_ctx, filter->_string_param);
return LikeColumnPredicate<TYPE_STRING>::create_shared(filter->_opposite, column_id,
column->name(), filter->_fn_ctx,
filter->_string_param);
}
throw Exception(ErrorCode::INTERNAL_ERROR, "function filter do not support type {}", PT);
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/olap/accept_null_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class AcceptNullPredicate : public ColumnPredicate {

public:
AcceptNullPredicate(const std::shared_ptr<ColumnPredicate>& nested)
: ColumnPredicate(nested->column_id(), nested->primitive_type(), nested->opposite()),
: ColumnPredicate(nested->column_id(), nested->col_name(), nested->primitive_type(),
nested->opposite()),
_nested {nested} {}
AcceptNullPredicate(const AcceptNullPredicate& other, uint32_t col_id)
: ColumnPredicate(other, col_id),
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/bitmap_filter_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class BitmapFilterColumnPredicate final : public ColumnPredicate {
using CppType = typename PrimitiveTypeTraits<T>::CppType;
using SpecificFilter = BitmapFilterFunc<T>;

BitmapFilterColumnPredicate(uint32_t column_id,
BitmapFilterColumnPredicate(uint32_t column_id, std::string col_name,
const std::shared_ptr<BitmapFilterFuncBase>& filter)
: ColumnPredicate(column_id, T),
: ColumnPredicate(column_id, col_name, T),
_filter(filter),
_specific_filter(assert_cast<SpecificFilter*>(_filter.get())) {}
~BitmapFilterColumnPredicate() override = default;
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/bloom_filter_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class BloomFilterColumnPredicate final : public ColumnPredicate {
ENABLE_FACTORY_CREATOR(BloomFilterColumnPredicate);
using SpecificFilter = BloomFilterFunc<T>;

BloomFilterColumnPredicate(uint32_t column_id,
BloomFilterColumnPredicate(uint32_t column_id, std::string col_name,
const std::shared_ptr<BloomFilterFuncBase>& filter)
: ColumnPredicate(column_id, T),
: ColumnPredicate(column_id, col_name, T),
_filter(filter),
_specific_filter(assert_cast<SpecificFilter*>(_filter.get())) {}
~BloomFilterColumnPredicate() override = default;
Expand Down
9 changes: 7 additions & 2 deletions be/src/olap/column_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ struct PredicateTypeTraits {

class ColumnPredicate : public std::enable_shared_from_this<ColumnPredicate> {
public:
explicit ColumnPredicate(uint32_t column_id, PrimitiveType primitive_type,
explicit ColumnPredicate(uint32_t column_id, std::string col_name, PrimitiveType primitive_type,
bool opposite = false)
: _column_id(column_id), _primitive_type(primitive_type), _opposite(opposite) {
: _column_id(column_id),
_col_name(col_name),
_primitive_type(primitive_type),
_opposite(opposite) {
reset_judge_selectivity();
}
ColumnPredicate(const ColumnPredicate& other, uint32_t col_id) : ColumnPredicate(other) {
Expand Down Expand Up @@ -316,6 +319,7 @@ class ColumnPredicate : public std::enable_shared_from_this<ColumnPredicate> {
DCHECK(false) << "should not reach here";
}
uint32_t column_id() const { return _column_id; }
std::string col_name() const { return _col_name; }

bool opposite() const { return _opposite; }

Expand Down Expand Up @@ -421,6 +425,7 @@ class ColumnPredicate : public std::enable_shared_from_this<ColumnPredicate> {
}

uint32_t _column_id;
const std::string _col_name;
PrimitiveType _primitive_type;
// TODO: the value is only in delete condition, better be template value
bool _opposite;
Expand Down
5 changes: 3 additions & 2 deletions be/src/olap/comparison_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class ComparisonPredicateBase final : public ColumnPredicate {
public:
ENABLE_FACTORY_CREATOR(ComparisonPredicateBase);
using T = typename PrimitiveTypeTraits<Type>::CppType;
ComparisonPredicateBase(uint32_t column_id, const T& value, bool opposite = false)
: ColumnPredicate(column_id, Type, opposite), _value(value) {}
ComparisonPredicateBase(uint32_t column_id, std::string col_name, const T& value,
bool opposite = false)
: ColumnPredicate(column_id, col_name, Type, opposite), _value(value) {}
ComparisonPredicateBase(const ComparisonPredicateBase<Type, PT>& other, uint32_t col_id)
: ColumnPredicate(other, col_id), _value(other._value) {}
ComparisonPredicateBase(const ComparisonPredicateBase<Type, PT>& other) = delete;
Expand Down
71 changes: 38 additions & 33 deletions be/src/olap/delete_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,42 +252,44 @@ Status convert(const vectorized::DataTypePtr& data_type, const std::list<std::st
v.size = sizeof(tmp); \
switch (res.condition_op) { \
case PredicateType::EQ: \
predicate = \
create_comparison_predicate0<PredicateType::EQ>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::EQ>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
case PredicateType::NE: \
predicate = \
create_comparison_predicate0<PredicateType::NE>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::NE>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
case PredicateType::GT: \
predicate = \
create_comparison_predicate0<PredicateType::GT>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::GT>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
case PredicateType::GE: \
predicate = \
create_comparison_predicate0<PredicateType::GE>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::GE>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
case PredicateType::LT: \
predicate = \
create_comparison_predicate0<PredicateType::LT>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::LT>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
case PredicateType::LE: \
predicate = \
create_comparison_predicate0<PredicateType::LE>(index, type, v, true, arena); \
predicate = create_comparison_predicate0<PredicateType::LE>(index, col_name, type, v, \
true, arena); \
return Status::OK(); \
default: \
return Status::Error<ErrorCode::INVALID_ARGUMENT>( \
"invalid condition operator. operator={}", type_to_op_str(res.condition_op)); \
} \
}
Status parse_to_predicate(const uint32_t index, const vectorized::DataTypePtr& type,
Status parse_to_predicate(const uint32_t index, const std::string col_name,
const vectorized::DataTypePtr& type,
DeleteHandler::ConditionParseResult& res, vectorized::Arena& arena,
std::shared_ptr<ColumnPredicate>& predicate) {
DCHECK_EQ(res.value_str.size(), 1);
if (res.condition_op == PredicateType::IS_NULL ||
res.condition_op == PredicateType::IS_NOT_NULL) {
predicate = NullPredicate::create_shared(
index, res.condition_op == PredicateType::IS_NOT_NULL, type->get_primitive_type());
predicate = NullPredicate::create_shared(index, col_name,
res.condition_op == PredicateType::IS_NOT_NULL,
type->get_primitive_type());
return Status::OK();
}
StringRef v;
Expand Down Expand Up @@ -318,28 +320,28 @@ Status parse_to_predicate(const uint32_t index, const vectorized::DataTypePtr& t
RETURN_IF_ERROR(convert<TYPE_STRING>(type, res.value_str.front(), arena, v));
switch (res.condition_op) {
case PredicateType::EQ:
predicate =
create_comparison_predicate0<PredicateType::EQ>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::EQ>(index, col_name, type, v,
true, arena);
return Status::OK();
case PredicateType::NE:
predicate =
create_comparison_predicate0<PredicateType::NE>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::NE>(index, col_name, type, v,
true, arena);
return Status::OK();
case PredicateType::GT:
predicate =
create_comparison_predicate0<PredicateType::GT>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::GT>(index, col_name, type, v,
true, arena);
return Status::OK();
case PredicateType::GE:
predicate =
create_comparison_predicate0<PredicateType::GE>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::GE>(index, col_name, type, v,
true, arena);
return Status::OK();
case PredicateType::LT:
predicate =
create_comparison_predicate0<PredicateType::LT>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::LT>(index, col_name, type, v,
true, arena);
return Status::OK();
case PredicateType::LE:
predicate =
create_comparison_predicate0<PredicateType::LE>(index, type, v, true, arena);
predicate = create_comparison_predicate0<PredicateType::LE>(index, col_name, type, v,
true, arena);
return Status::OK();
default:
return Status::Error<ErrorCode::INVALID_ARGUMENT>(
Expand All @@ -356,21 +358,24 @@ Status parse_to_predicate(const uint32_t index, const vectorized::DataTypePtr& t
#undef CONVERT_CASE
}

Status parse_to_in_predicate(const uint32_t index, const vectorized::DataTypePtr& type,
Status parse_to_in_predicate(const uint32_t index, const std::string& col_name,
const vectorized::DataTypePtr& type,
DeleteHandler::ConditionParseResult& res, vectorized::Arena& arena,
std::shared_ptr<ColumnPredicate>& predicate) {
DCHECK_GT(res.value_str.size(), 1);
switch (res.condition_op) {
case PredicateType::IN_LIST: {
std::shared_ptr<HybridSetBase> set;
RETURN_IF_ERROR(convert(type, res.value_str, arena, set));
predicate = create_in_list_predicate<PredicateType::IN_LIST>(index, type, set, true);
predicate =
create_in_list_predicate<PredicateType::IN_LIST>(index, col_name, type, set, true);
break;
}
case PredicateType::NOT_IN_LIST: {
std::shared_ptr<HybridSetBase> set;
RETURN_IF_ERROR(convert(type, res.value_str, arena, set));
predicate = create_in_list_predicate<PredicateType::NOT_IN_LIST>(index, type, set, true);
predicate = create_in_list_predicate<PredicateType::NOT_IN_LIST>(index, col_name, type, set,
true);
break;
}
default:
Expand Down Expand Up @@ -741,7 +746,7 @@ Status DeleteHandler::_parse_column_pred(TabletSchemaSPtr complete_schema,
const auto& column = complete_schema->column_by_uid(col_unique_id);
uint32_t index = complete_schema->field_index(col_unique_id);
std::shared_ptr<ColumnPredicate> predicate;
RETURN_IF_ERROR(parse_to_predicate(index, column.get_vec_type(), condition,
RETURN_IF_ERROR(parse_to_predicate(index, column.name(), column.get_vec_type(), condition,
_predicate_arena, predicate));
if (predicate != nullptr) {
delete_conditions->column_predicate_vec.push_back(predicate);
Expand Down Expand Up @@ -800,8 +805,8 @@ Status DeleteHandler::init(TabletSchemaSPtr tablet_schema,
const auto& column = tablet_schema->column_by_uid(col_unique_id);
uint32_t index = tablet_schema->field_index(col_unique_id);
std::shared_ptr<ColumnPredicate> predicate;
RETURN_IF_ERROR(parse_to_in_predicate(index, column.get_vec_type(), condition,
_predicate_arena, predicate));
RETURN_IF_ERROR(parse_to_in_predicate(index, column.name(), column.get_vec_type(),
condition, _predicate_arena, predicate));
temp.column_predicate_vec.push_back(predicate);
}

Expand Down
30 changes: 4 additions & 26 deletions be/src/olap/in_list_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,10 @@ class InListPredicateBase final : public ColumnPredicate {
std::is_same_v<T, StringRef>, StringSet<DynamicContainer<std::string>>,
HybridSet<Type, DynamicContainer<T>,
vectorized::PredicateColumnType<PredicateEvaluateType<Type>>>>>;
template <typename ConditionType, typename ConvertFunc>
InListPredicateBase(uint32_t column_id, const ConditionType& conditions,
const ConvertFunc& convert, bool is_opposite,
const vectorized::DataTypePtr& data_type, vectorized::Arena& arena)
: ColumnPredicate(column_id, Type, is_opposite),
_min_value(type_limit<T>::max()),
_max_value(type_limit<T>::min()) {
_values = std::make_shared<HybridSetType>(false);
for (const auto& condition : conditions) {
T tmp;
if constexpr (Type == TYPE_STRING || Type == TYPE_CHAR) {
tmp = convert(data_type, condition, arena);
} else if constexpr (Type == TYPE_DECIMAL32 || Type == TYPE_DECIMAL64 ||
Type == TYPE_DECIMAL128I || Type == TYPE_DECIMAL256) {
tmp = convert(data_type, condition);
} else {
tmp = convert(condition);
}
_values->insert(&tmp);
_update_min_max(tmp);
}
}

InListPredicateBase(uint32_t column_id, const std::shared_ptr<HybridSetBase>& hybrid_set,
bool is_opposite, size_t char_length = 0)
: ColumnPredicate(column_id, Type, is_opposite),
InListPredicateBase(uint32_t column_id, std::string col_name,
const std::shared_ptr<HybridSetBase>& hybrid_set, bool is_opposite,
size_t char_length = 0)
: ColumnPredicate(column_id, col_name, Type, is_opposite),
_min_value(type_limit<T>::max()),
_max_value(type_limit<T>::min()) {
CHECK(hybrid_set != nullptr);
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/like_column_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
namespace doris {

template <PrimitiveType T>
LikeColumnPredicate<T>::LikeColumnPredicate(bool opposite, uint32_t column_id,
LikeColumnPredicate<T>::LikeColumnPredicate(bool opposite, uint32_t column_id, std::string col_name,
doris::FunctionContext* fn_ctx, doris::StringRef val)
: ColumnPredicate(column_id, T, opposite), pattern(val) {
: ColumnPredicate(column_id, col_name, T, opposite), pattern(val) {
static_assert(T == TYPE_VARCHAR || T == TYPE_CHAR || T == TYPE_STRING,
"LikeColumnPredicate only supports the following types: TYPE_VARCHAR, TYPE_CHAR, "
"TYPE_STRING");
Expand Down
Loading
Loading