[Bug](decimalv3) fix failed on test_dup_tab_decimalv3 due to wrong precision (#21890)
fix failed on test_dup_tab_decimalv3 due to wrong precision
This commit is contained in:
@ -65,9 +65,12 @@
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
#define RETURN_IF_PUSH_DOWN(stmt) \
|
||||
#define RETURN_IF_PUSH_DOWN(stmt, status) \
|
||||
if (pdt == PushDownType::UNACCEPTABLE) { \
|
||||
stmt; \
|
||||
status = stmt; \
|
||||
if (!status.ok()) { \
|
||||
return; \
|
||||
} \
|
||||
} else { \
|
||||
return; \
|
||||
}
|
||||
@ -472,6 +475,7 @@ Status VScanNode::_normalize_predicate(const VExprSPtr& conjunct_expr_root, VExp
|
||||
}
|
||||
if (_is_predicate_acting_on_slot(cur_expr, in_predicate_checker, &slot, &range) ||
|
||||
_is_predicate_acting_on_slot(cur_expr, eq_predicate_checker, &slot, &range)) {
|
||||
Status status = Status::OK();
|
||||
std::visit(
|
||||
[&](auto& value_range) {
|
||||
Defer mark_runtime_filter_flag {[&]() {
|
||||
@ -479,27 +483,36 @@ Status VScanNode::_normalize_predicate(const VExprSPtr& conjunct_expr_root, VExp
|
||||
_is_runtime_filter_predicate);
|
||||
}};
|
||||
RETURN_IF_PUSH_DOWN(_normalize_in_and_eq_predicate(
|
||||
cur_expr, context, slot, value_range, &pdt));
|
||||
cur_expr, context, slot, value_range, &pdt),
|
||||
status);
|
||||
RETURN_IF_PUSH_DOWN(_normalize_not_in_and_not_eq_predicate(
|
||||
cur_expr, context, slot, value_range, &pdt));
|
||||
cur_expr, context, slot, value_range, &pdt),
|
||||
status);
|
||||
RETURN_IF_PUSH_DOWN(_normalize_is_null_predicate(
|
||||
cur_expr, context, slot, value_range, &pdt));
|
||||
cur_expr, context, slot, value_range, &pdt),
|
||||
status);
|
||||
RETURN_IF_PUSH_DOWN(_normalize_noneq_binary_predicate(
|
||||
cur_expr, context, slot, value_range, &pdt));
|
||||
cur_expr, context, slot, value_range, &pdt),
|
||||
status);
|
||||
RETURN_IF_PUSH_DOWN(_normalize_match_predicate(cur_expr, context, slot,
|
||||
value_range, &pdt));
|
||||
value_range, &pdt),
|
||||
status);
|
||||
if (_is_key_column(slot->col_name())) {
|
||||
RETURN_IF_PUSH_DOWN(
|
||||
_normalize_bitmap_filter(cur_expr, context, slot, &pdt));
|
||||
_normalize_bitmap_filter(cur_expr, context, slot, &pdt),
|
||||
status);
|
||||
RETURN_IF_PUSH_DOWN(
|
||||
_normalize_bloom_filter(cur_expr, context, slot, &pdt));
|
||||
_normalize_bloom_filter(cur_expr, context, slot, &pdt),
|
||||
status);
|
||||
if (_state->enable_function_pushdown()) {
|
||||
RETURN_IF_PUSH_DOWN(_normalize_function_filters(
|
||||
cur_expr, context, slot, &pdt));
|
||||
cur_expr, context, slot, &pdt),
|
||||
status);
|
||||
}
|
||||
}
|
||||
},
|
||||
*range);
|
||||
RETURN_IF_ERROR(status);
|
||||
}
|
||||
|
||||
if (pdt == PushDownType::UNACCEPTABLE &&
|
||||
@ -772,6 +785,11 @@ Status VScanNode::_normalize_in_and_eq_predicate(VExpr* expr, VExprContext* expr
|
||||
temp_range, reinterpret_cast<void*>(&val),
|
||||
ColumnValueRange<T>::add_fixed_value_range, fn_name));
|
||||
} else {
|
||||
if (sizeof(typename PrimitiveTypeTraits<T>::CppType) != value.size) {
|
||||
return Status::InternalError(
|
||||
"PrimitiveType {} meet invalid input value size {}, expect size {}", T,
|
||||
value.size, sizeof(typename PrimitiveTypeTraits<T>::CppType));
|
||||
}
|
||||
RETURN_IF_ERROR(_change_value_range<true>(
|
||||
temp_range, reinterpret_cast<void*>(const_cast<char*>(value.data)),
|
||||
ColumnValueRange<T>::add_fixed_value_range, fn_name));
|
||||
|
||||
@ -46,8 +46,6 @@ import org.apache.doris.nereids.types.DateV2Type;
|
||||
import org.apache.doris.nereids.types.DecimalV3Type;
|
||||
import org.apache.doris.nereids.types.coercion.DateLikeType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* simplify comparison
|
||||
* such as: cast(c1 as DateV2) >= DateV2Literal --> c1 >= DateLiteral
|
||||
@ -214,9 +212,8 @@ public class SimplifyComparisonPredicate extends AbstractExpressionRewriteRule {
|
||||
int toScale = ((DecimalV3Type) left.getDataType()).getScale();
|
||||
if (comparisonPredicate instanceof EqualTo) {
|
||||
try {
|
||||
BigDecimal newValue = literal.getValue().setScale(toScale);
|
||||
return comparisonPredicate.withChildren(left,
|
||||
new DecimalV3Literal(newValue));
|
||||
return comparisonPredicate.withChildren(left, new DecimalV3Literal(
|
||||
(DecimalV3Type) left.getDataType(), literal.getValue().setScale(toScale)));
|
||||
} catch (ArithmeticException e) {
|
||||
if (left.nullable()) {
|
||||
// TODO: the ideal way is to return an If expr like:
|
||||
@ -232,9 +229,8 @@ public class SimplifyComparisonPredicate extends AbstractExpressionRewriteRule {
|
||||
}
|
||||
} else if (comparisonPredicate instanceof NullSafeEqual) {
|
||||
try {
|
||||
BigDecimal newValue = literal.getValue().setScale(toScale);
|
||||
return comparisonPredicate.withChildren(left,
|
||||
new DecimalV3Literal(newValue));
|
||||
return comparisonPredicate.withChildren(left, new DecimalV3Literal(
|
||||
(DecimalV3Type) left.getDataType(), literal.getValue().setScale(toScale)));
|
||||
} catch (ArithmeticException e) {
|
||||
return BooleanLiteral.of(false);
|
||||
}
|
||||
|
||||
@ -211,3 +211,13 @@
|
||||
2.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
2.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
|
||||
-- !select_in_pred_decimal64_key2 --
|
||||
1.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
1.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
1.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
1.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
1.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
2.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
2.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
2.10000 1.20000 1.30000 1.40000 1.50000 1.60000
|
||||
|
||||
|
||||
@ -86,5 +86,8 @@ suite("test_dup_tab_decimalv3") {
|
||||
qt_select_in_pred_decimal128_key2 "select * from ${table1} where decimal128_key in(1.30000000000) order by decimal32_key"
|
||||
qt_select_in_pred_decimal128_key3 "select * from ${table1} where decimal128_key in(1.3, 1.4) order by decimal32_key"
|
||||
|
||||
sql "set enable_nereids_planner=true;"
|
||||
qt_select_in_pred_decimal64_key2 "select * from ${table1} where decimal64_key in(1.20000000000) order by decimal32_key"
|
||||
|
||||
sql "drop table if exists ${table1}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user