[feature-wip](datev2) Support to use datev2 as partition column (#11618)
This commit is contained in:
@ -811,7 +811,8 @@ static bool ignore_cast(SlotDescriptor* slot, VExpr* expr) {
|
||||
template <bool IsFixed, PrimitiveType PrimitiveType, typename ChangeFixedValueRangeFunc>
|
||||
Status VOlapScanNode::change_value_range(ColumnValueRange<PrimitiveType>& temp_range, void* value,
|
||||
const ChangeFixedValueRangeFunc& func,
|
||||
const std::string& fn_name, int slot_ref_child) {
|
||||
const std::string& fn_name, bool cast_date_to_datetime,
|
||||
int slot_ref_child) {
|
||||
if constexpr (PrimitiveType == TYPE_DATE) {
|
||||
DateTimeValue date_value;
|
||||
reinterpret_cast<VecDateTimeValue*>(value)->convert_vec_dt_to_dt(&date_value);
|
||||
@ -844,27 +845,39 @@ Status VOlapScanNode::change_value_range(ColumnValueRange<PrimitiveType>& temp_r
|
||||
reinterpret_cast<char*>(&date_value)));
|
||||
}
|
||||
} else if constexpr (PrimitiveType == TYPE_DATEV2) {
|
||||
DateV2Value<DateTimeV2ValueType> datetimev2_value =
|
||||
*reinterpret_cast<DateV2Value<DateTimeV2ValueType>*>(value);
|
||||
if constexpr (IsFixed) {
|
||||
if (datetimev2_value.can_cast_to_date_without_loss_accuracy()) {
|
||||
DateV2Value<DateV2ValueType> date_v2;
|
||||
if (cast_date_to_datetime) {
|
||||
DateV2Value<DateTimeV2ValueType> datetimev2_value =
|
||||
*reinterpret_cast<DateV2Value<DateTimeV2ValueType>*>(value);
|
||||
if constexpr (IsFixed) {
|
||||
if (datetimev2_value.can_cast_to_date_without_loss_accuracy()) {
|
||||
DateV2Value<DateV2ValueType> date_v2;
|
||||
date_v2.set_date_uint32(binary_cast<DateV2Value<DateTimeV2ValueType>, uint64_t>(
|
||||
datetimev2_value) >>
|
||||
TIME_PART_LENGTH);
|
||||
func(temp_range, &date_v2);
|
||||
}
|
||||
} else {
|
||||
doris::vectorized::DateV2Value<DateV2ValueType> date_v2;
|
||||
date_v2.set_date_uint32(
|
||||
binary_cast<DateV2Value<DateTimeV2ValueType>, uint64_t>(datetimev2_value) >>
|
||||
TIME_PART_LENGTH);
|
||||
func(temp_range, &date_v2);
|
||||
if (!datetimev2_value.can_cast_to_date_without_loss_accuracy()) {
|
||||
if (fn_name == "lt" || fn_name == "ge") {
|
||||
++date_v2;
|
||||
}
|
||||
}
|
||||
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child), &date_v2);
|
||||
}
|
||||
} else {
|
||||
doris::vectorized::DateV2Value<DateV2ValueType> date_v2;
|
||||
date_v2.set_date_uint32(
|
||||
binary_cast<DateV2Value<DateTimeV2ValueType>, uint64_t>(datetimev2_value) >>
|
||||
TIME_PART_LENGTH);
|
||||
if (!datetimev2_value.can_cast_to_date_without_loss_accuracy()) {
|
||||
if (fn_name == "lt" || fn_name == "ge") {
|
||||
++date_v2;
|
||||
}
|
||||
if constexpr (IsFixed) {
|
||||
func(temp_range,
|
||||
reinterpret_cast<typename PrimitiveTypeTraits<PrimitiveType>::CppType*>(
|
||||
value));
|
||||
} else {
|
||||
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child),
|
||||
reinterpret_cast<typename PrimitiveTypeTraits<PrimitiveType>::CppType*>(
|
||||
value));
|
||||
}
|
||||
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child), &date_v2);
|
||||
}
|
||||
} else if constexpr ((PrimitiveType == TYPE_DECIMALV2) || (PrimitiveType == TYPE_CHAR) ||
|
||||
(PrimitiveType == TYPE_VARCHAR) || (PrimitiveType == TYPE_HLL) ||
|
||||
@ -1503,8 +1516,9 @@ Status VOlapScanNode::_normalize_in_and_eq_predicate(VExpr* expr, VExprContext*
|
||||
continue;
|
||||
}
|
||||
auto value = const_cast<void*>(iter->get_value());
|
||||
RETURN_IF_ERROR(change_value_range<true>(
|
||||
temp_range, value, ColumnValueRange<T>::add_fixed_value_range, fn_name));
|
||||
RETURN_IF_ERROR(change_value_range<true>(temp_range, value,
|
||||
ColumnValueRange<T>::add_fixed_value_range,
|
||||
fn_name, !state->hybrid_set->is_date_v2()));
|
||||
iter->next();
|
||||
}
|
||||
|
||||
@ -1577,10 +1591,12 @@ Status VOlapScanNode::_normalize_not_in_and_not_eq_predicate(VExpr* expr, VExprC
|
||||
auto value = const_cast<void*>(iter->get_value());
|
||||
if (is_fixed_range) {
|
||||
RETURN_IF_ERROR(change_value_range<true>(
|
||||
range, value, ColumnValueRange<T>::remove_fixed_value_range, fn_name));
|
||||
range, value, ColumnValueRange<T>::remove_fixed_value_range, fn_name,
|
||||
!state->hybrid_set->is_date_v2()));
|
||||
} else {
|
||||
RETURN_IF_ERROR(change_value_range<true>(
|
||||
not_in_range, value, ColumnValueRange<T>::add_fixed_value_range, fn_name));
|
||||
not_in_range, value, ColumnValueRange<T>::add_fixed_value_range, fn_name,
|
||||
!state->hybrid_set->is_date_v2()));
|
||||
}
|
||||
iter->next();
|
||||
}
|
||||
@ -1687,11 +1703,11 @@ Status VOlapScanNode::_normalize_noneq_binary_predicate(VExpr* expr, VExprContex
|
||||
auto val = StringValue(value.data, value.size);
|
||||
RETURN_IF_ERROR(change_value_range<false>(range, reinterpret_cast<void*>(&val),
|
||||
ColumnValueRange<T>::add_value_range,
|
||||
fn_name, slot_ref_child));
|
||||
fn_name, true, slot_ref_child));
|
||||
} else {
|
||||
RETURN_IF_ERROR(change_value_range<false>(
|
||||
range, reinterpret_cast<void*>(const_cast<char*>(value.data)),
|
||||
ColumnValueRange<T>::add_value_range, fn_name, slot_ref_child));
|
||||
ColumnValueRange<T>::add_value_range, fn_name, true, slot_ref_child));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user