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
2 changes: 0 additions & 2 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,6 @@ CONF_mInt32(orc_natural_read_size_mb, "8");
// if it is lower than a specific threshold, the predicate will be disabled.
CONF_mInt32(bloom_filter_predicate_check_row_num, "204800");

CONF_Bool(enable_decimalv3, "false");

//whether turn on quick compaction feature
CONF_Bool(enable_quick_compaction, "false");
// For continuous versions that rows less than quick_compaction_max_rows will trigger compaction quickly
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/csv_scan_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ bool CsvScanNode::check_and_write_text_slot(const std::string& column_name,
char_len);
value_to_convert_length = char_len;
}
} else if (slot->type().is_decimal_type()) {
} else if (slot->type().is_decimal_v2_type()) {
int precision = column_type.precision;
int scale = column_type.scale;
bool is_success = check_decimal_input(value, value_length, precision, scale, error_msg);
Expand Down
4 changes: 2 additions & 2 deletions be/src/exec/olap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ std::string cast_to_string(T value, int scale) {
std::stringstream ss;
vectorized::write_text<int64_t>((int64_t)value, scale, ss);
return ss.str();
} else if constexpr (primitive_type == TYPE_DECIMAL128) {
} else if constexpr (primitive_type == TYPE_DECIMAL128I) {
std::stringstream ss;
vectorized::write_text<int128_t>((int128_t)value, scale, ss);
return ss.str();
Expand Down Expand Up @@ -389,7 +389,7 @@ using ColumnValueRangeType =
ColumnValueRange<TYPE_DATETIME>, ColumnValueRange<TYPE_DATETIMEV2>,
ColumnValueRange<TYPE_DECIMALV2>, ColumnValueRange<TYPE_BOOLEAN>,
ColumnValueRange<TYPE_HLL>, ColumnValueRange<TYPE_DECIMAL32>,
ColumnValueRange<TYPE_DECIMAL64>, ColumnValueRange<TYPE_DECIMAL128>>;
ColumnValueRange<TYPE_DECIMAL64>, ColumnValueRange<TYPE_DECIMAL128I>>;

template <PrimitiveType primitive_type>
const typename ColumnValueRange<primitive_type>::CppType
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/table_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Status TableConnector::append(const std::string& table_name, vectorized::Block*
}
case TYPE_DECIMAL32:
case TYPE_DECIMAL64:
case TYPE_DECIMAL128: {
case TYPE_DECIMAL128I: {
auto val = type_ptr->to_string(*column, i);
fmt::format_to(_insert_stmt_buffer, "{}", val);
break;
Expand Down
6 changes: 3 additions & 3 deletions be/src/exprs/anyval_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ AnyVal* create_any_val(ObjectPool* pool, const TypeDescriptor& type) {
case TYPE_DECIMAL64:
return pool->add(new BigIntVal);

case TYPE_DECIMAL128:
case TYPE_DECIMAL128I:
return pool->add(new LargeIntVal);

case TYPE_DATE:
Expand Down Expand Up @@ -175,8 +175,8 @@ FunctionContext::TypeDesc AnyValUtil::column_type_to_type_desc(const TypeDescrip
out.precision = type.precision;
out.scale = type.scale;
break;
case TYPE_DECIMAL128:
out.type = FunctionContext::TYPE_DECIMAL128;
case TYPE_DECIMAL128I:
out.type = FunctionContext::TYPE_DECIMAL128I;
out.precision = type.precision;
out.scale = type.scale;
break;
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/anyval_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class AnyValUtil {
reinterpret_cast<doris_udf::Decimal64Val*>(dst)->val =
*reinterpret_cast<const int64_t*>(slot);
return;
case TYPE_DECIMAL128:
case TYPE_DECIMAL128I:
memcpy(&reinterpret_cast<doris_udf::Decimal128Val*>(dst)->val, slot, sizeof(__int128));
return;

Expand Down
14 changes: 7 additions & 7 deletions be/src/exprs/binary_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new EqBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new EqLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new EqFloatValPred(node);
Expand Down Expand Up @@ -81,7 +81,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new NeBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new NeLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new NeFloatValPred(node);
Expand Down Expand Up @@ -118,7 +118,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new LtBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new LtLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new LtFloatValPred(node);
Expand Down Expand Up @@ -155,7 +155,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new LeBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new LeLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new LeFloatValPred(node);
Expand Down Expand Up @@ -192,7 +192,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new GtBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new GtLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new GtFloatValPred(node);
Expand Down Expand Up @@ -229,7 +229,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new GeBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new GeLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new GeFloatValPred(node);
Expand Down Expand Up @@ -266,7 +266,7 @@ Expr* BinaryPredicate::from_thrift(const TExprNode& node) {
case TPrimitiveType::DATETIMEV2:
return new EqForNullBigIntValPred(node);
case TPrimitiveType::LARGEINT:
case TPrimitiveType::DECIMAL128:
case TPrimitiveType::DECIMAL128I:
return new EqForNullLargeIntValPred(node);
case TPrimitiveType::FLOAT:
return new EqForNullFloatValPred(node);
Expand Down
249 changes: 0 additions & 249 deletions be/src/exprs/cast_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "util/array_parser.h"
#include "util/mysql_global.h"
#include "util/string_parser.hpp"
#include "vec/data_types/data_type_decimal.h"
#include "vec/runtime/vdatetime_value.h"

namespace doris {
Expand Down Expand Up @@ -362,254 +361,6 @@ DateTimeVal CastFunctions::cast_to_date_val(FunctionContext* ctx, const StringVa
return result;
}

#define CAST_TYPE_DECIMAL32(from_type) \
Decimal32Val CastFunctions::cast_to_decimal32_val(FunctionContext* ctx, \
const from_type& val) { \
if (val.is_null) { \
return Decimal32Val::null(); \
} \
auto scale_to = ctx->get_return_type().scale; \
return Decimal32Val( \
val.val * \
vectorized::DataTypeDecimal<vectorized::Decimal32>::get_scale_multiplier( \
scale_to)); \
}

#define CAST_TYPE_DECIMAL64(from_type) \
Decimal64Val CastFunctions::cast_to_decimal64_val(FunctionContext* ctx, \
const from_type& val) { \
if (val.is_null) { \
return Decimal64Val::null(); \
} \
auto scale_to = ctx->get_return_type().scale; \
return Decimal64Val( \
val.val * \
vectorized::DataTypeDecimal<vectorized::Decimal64>::get_scale_multiplier( \
scale_to)); \
}

#define CAST_TYPE_DECIMAL128(from_type) \
Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* ctx, \
const from_type& val) { \
if (val.is_null) { \
return Decimal128Val::null(); \
} \
auto scale_to = ctx->get_return_type().scale; \
return Decimal128Val( \
val.val * \
vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier( \
scale_to)); \
}

#define CAST_TYPE_DECIMAL(to_type) \
CAST_TYPE_##to_type(TinyIntVal) CAST_TYPE_##to_type(SmallIntVal) CAST_TYPE_##to_type(IntVal) \
CAST_TYPE_##to_type(BigIntVal) CAST_TYPE_##to_type(LargeIntVal) \
CAST_TYPE_##to_type(FloatVal) CAST_TYPE_##to_type(DoubleVal)

CAST_TYPE_DECIMAL(DECIMAL32)
CAST_TYPE_DECIMAL(DECIMAL64)
CAST_TYPE_DECIMAL(DECIMAL128)

Decimal32Val CastFunctions::cast_to_decimal32_val(FunctionContext* context,
const DateTimeVal& val) {
if (val.is_null) {
return Decimal32Val::null();
}
auto scale_to = context->get_return_type().scale;
DateTimeValue dt_value = DateTimeValue::from_datetime_val(val);
return Decimal32Val(
dt_value.to_int64() *
vectorized::DataTypeDecimal<vectorized::Decimal32>::get_scale_multiplier(scale_to));
}

Decimal32Val CastFunctions::cast_to_decimal32_val(FunctionContext* context, const StringVal& val) {
if (val.is_null) {
return Decimal32Val::null();
}
std::stringstream ss;
StringParser::ParseResult result;
int32_t v = StringParser::string_to_decimal<int32_t>((const char*)val.ptr, val.len,
context->get_return_type().precision,
context->get_return_type().scale, &result);
return Decimal32Val(v);
}

Decimal32Val CastFunctions::cast_to_decimal32_val(FunctionContext* ctx, const Decimal32Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return val;
}
if (val.is_null) {
return Decimal32Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal32Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal32>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal32Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal32>::get_scale_multiplier(
scale_from - scale_to));
}
}

Decimal64Val CastFunctions::cast_to_decimal64_val(FunctionContext* context,
const DateTimeVal& val) {
if (val.is_null) {
return Decimal64Val::null();
}
auto scale_to = context->get_return_type().scale;
DateTimeValue dt_value = DateTimeValue::from_datetime_val(val);
return Decimal64Val(
dt_value.to_int64() *
vectorized::DataTypeDecimal<vectorized::Decimal64>::get_scale_multiplier(scale_to));
}

Decimal64Val CastFunctions::cast_to_decimal64_val(FunctionContext* context, const StringVal& val) {
if (val.is_null) {
return Decimal64Val::null();
}
std::stringstream ss;
StringParser::ParseResult result;
int64_t v = StringParser::string_to_decimal<int64_t>((const char*)val.ptr, val.len,
context->get_return_type().precision,
context->get_return_type().scale, &result);
return Decimal64Val(v);
}

Decimal64Val CastFunctions::cast_to_decimal64_val(FunctionContext* ctx, const Decimal64Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return val;
}
if (val.is_null) {
return Decimal64Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal64Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal64>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal64Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal64>::get_scale_multiplier(
scale_from - scale_to));
}
}

Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* context,
const DateTimeVal& val) {
if (val.is_null) {
return Decimal128Val::null();
}
auto scale_to = context->get_return_type().scale;
DateTimeValue dt_value = DateTimeValue::from_datetime_val(val);
return Decimal128Val(
dt_value.to_int64() *
vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(scale_to));
}

Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* context,
const StringVal& val) {
if (val.is_null) {
return Decimal128Val::null();
}
std::stringstream ss;
StringParser::ParseResult result;
int128_t v = StringParser::string_to_decimal<int128_t>(
(const char*)val.ptr, val.len, context->get_return_type().precision,
context->get_return_type().scale, &result);
return Decimal128Val(v);
}

Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* ctx,
const Decimal128Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return val;
}
if (val.is_null) {
return Decimal128Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal128Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal128Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_from - scale_to));
}
}

Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* ctx, const Decimal32Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return Decimal128Val(val.val);
}
if (val.is_null) {
return Decimal128Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal128Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal128Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_from - scale_to));
}
}

Decimal128Val CastFunctions::cast_to_decimal128_val(FunctionContext* ctx, const Decimal64Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return Decimal128Val(val.val);
}
if (val.is_null) {
return Decimal128Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal128Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal128Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_from - scale_to));
}
}

Decimal64Val CastFunctions::cast_to_decimal64_val(FunctionContext* ctx, const Decimal32Val& val) {
if (ctx->get_arg_type(0)->scale == ctx->get_return_type().scale &&
ctx->get_arg_type(0)->precision == ctx->get_return_type().precision) {
return Decimal64Val(val.val);
}
if (val.is_null) {
return Decimal64Val::null();
}
auto scale_from = ctx->get_arg_type(0)->scale;
auto scale_to = ctx->get_return_type().scale;
if (scale_to > scale_from) {
return Decimal64Val(
val.val * vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_to - scale_from));
} else {
return Decimal64Val(
val.val / vectorized::DataTypeDecimal<vectorized::Decimal128>::get_scale_multiplier(
scale_from - scale_to));
}
}

DateTimeVal CastFunctions::cast_to_date_val(FunctionContext* ctx, const DateV2Val& val) {
if (val.is_null) {
return DateTimeVal::null();
Expand Down
Loading