[fix](datetimev2) Fix BE datetimev2 type returning wrong result (#15885)
This commit is contained in:
@ -337,8 +337,7 @@ int VMysqlResultWriter<is_binary_format>::_add_one_cell(const ColumnPtr& column_
|
||||
} else if (which.is_date_or_datetime()) {
|
||||
auto& column_vector = assert_cast<const ColumnVector<Int64>&>(*column);
|
||||
auto value = column_vector[row_idx].get<Int64>();
|
||||
VecDateTimeValue datetime;
|
||||
memcpy(static_cast<void*>(&datetime), static_cast<void*>(&value), sizeof(value));
|
||||
VecDateTimeValue datetime = binary_cast<Int64, VecDateTimeValue>(value);
|
||||
if (which.is_date()) {
|
||||
datetime.cast_to_date();
|
||||
}
|
||||
@ -348,11 +347,19 @@ int VMysqlResultWriter<is_binary_format>::_add_one_cell(const ColumnPtr& column_
|
||||
} else if (which.is_date_v2()) {
|
||||
auto& column_vector = assert_cast<const ColumnVector<UInt32>&>(*column);
|
||||
auto value = column_vector[row_idx].get<UInt32>();
|
||||
DateV2Value<DateV2ValueType> datev2;
|
||||
memcpy(static_cast<void*>(&datev2), static_cast<void*>(&value), sizeof(value));
|
||||
DateV2Value<DateV2ValueType> datev2 =
|
||||
binary_cast<UInt32, DateV2Value<DateV2ValueType>>(value);
|
||||
char buf[64];
|
||||
char* pos = datev2.to_string(buf);
|
||||
return buffer.push_string(buf, pos - buf - 1);
|
||||
} else if (which.is_date_time_v2()) {
|
||||
auto& column_vector = assert_cast<const ColumnVector<UInt64>&>(*column);
|
||||
auto value = column_vector[row_idx].get<UInt64>();
|
||||
DateV2Value<DateTimeV2ValueType> datetimev2 =
|
||||
binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>(value);
|
||||
char buf[64];
|
||||
char* pos = datetimev2.to_string(buf);
|
||||
return buffer.push_string(buf, pos - buf - 1);
|
||||
} else if (which.is_decimal32()) {
|
||||
DataTypePtr nested_type = type;
|
||||
if (type->is_nullable()) {
|
||||
|
||||
Reference in New Issue
Block a user