be/src/exprs/function/cast/cast_to_float.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <type_traits> |
21 | | |
22 | | #include "core/data_type/data_type_decimal.h" |
23 | | #include "core/data_type/data_type_number.h" |
24 | | #include "core/data_type/primitive_type.h" |
25 | | #include "exprs/function/cast/cast_to_basic_number_common.h" |
26 | | |
27 | | namespace doris { |
28 | | #include "common/compile_check_begin.h" |
29 | | // cast bool, integer, float to double, will not overflow |
30 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
31 | | requires(IsDataTypeFloat<ToDataType> && IsDataTypeNumber<FromDataType>) |
32 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
33 | | public: |
34 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
35 | | uint32_t result, size_t input_rows_count, |
36 | 101 | const NullMap::value_type* null_map = nullptr) const override { |
37 | 101 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, |
38 | 101 | input_rows_count); |
39 | 101 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 74 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 74 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 74 | input_rows_count); | 39 | 74 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 36 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 37 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 38 | 1 | input_rows_count); | 39 | 1 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh |
40 | | }; |
41 | | |
42 | | // cast decimal to float and double |
43 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
44 | | requires(IsDataTypeFloat<ToDataType> && IsDataTypeDecimal<FromDataType>) |
45 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
46 | | public: |
47 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
48 | | uint32_t result, size_t input_rows_count, |
49 | 182 | const NullMap::value_type* null_map = nullptr) const override { |
50 | 182 | using FromFieldType = typename FromDataType::FieldType; |
51 | 182 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
52 | 182 | const auto* col_from = |
53 | 182 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
54 | 182 | if (!col_from) { |
55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", |
56 | 0 | type_to_string(FromDataType::PType), |
57 | 0 | named_from.column->get_name())); |
58 | 0 | } |
59 | 182 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); |
60 | 182 | UInt32 from_scale = from_decimal_type.get_scale(); |
61 | | |
62 | 182 | auto col_to = ToDataType::ColumnType::create(input_rows_count); |
63 | 182 | const auto& vec_from = col_from->get_data(); |
64 | 182 | const auto* vec_from_data = vec_from.data(); |
65 | 182 | auto& vec_to = col_to->get_data(); |
66 | 182 | auto* vec_to_data = vec_to.data(); |
67 | | |
68 | 182 | CastParameters params; |
69 | 182 | params.is_strict = (CastMode == CastModeType::StrictMode); |
70 | 182 | size_t size = vec_from.size(); |
71 | | |
72 | 182 | typename FromFieldType::NativeType scale_multiplier = |
73 | 182 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); |
74 | 8.33k | for (size_t i = 0; i < size; ++i) { |
75 | 8.14k | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], |
76 | 8.14k | scale_multiplier, params); |
77 | 8.14k | } |
78 | | |
79 | 182 | block.get_by_position(result).column = std::move(col_to); |
80 | 182 | return Status::OK(); |
81 | 182 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 311 | for (size_t i = 0; i < size; ++i) { | 75 | 304 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 304 | scale_multiplier, params); | 77 | 304 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 311 | for (size_t i = 0; i < size; ++i) { | 75 | 304 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 304 | scale_multiplier, params); | 77 | 304 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 129 | for (size_t i = 0; i < size; ++i) { | 75 | 122 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 122 | scale_multiplier, params); | 77 | 122 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 129 | for (size_t i = 0; i < size; ++i) { | 75 | 122 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 122 | scale_multiplier, params); | 77 | 122 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 18 | using FromFieldType = typename FromDataType::FieldType; | 51 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 18 | const auto* col_from = | 53 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 18 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 18 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 18 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 18 | const auto& vec_from = col_from->get_data(); | 64 | 18 | const auto* vec_from_data = vec_from.data(); | 65 | 18 | auto& vec_to = col_to->get_data(); | 66 | 18 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 18 | CastParameters params; | 69 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 18 | size_t size = vec_from.size(); | 71 | | | 72 | 18 | typename FromFieldType::NativeType scale_multiplier = | 73 | 18 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 680 | for (size_t i = 0; i < size; ++i) { | 75 | 662 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 662 | scale_multiplier, params); | 77 | 662 | } | 78 | | | 79 | 18 | block.get_by_position(result).column = std::move(col_to); | 80 | 18 | return Status::OK(); | 81 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 18 | using FromFieldType = typename FromDataType::FieldType; | 51 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 18 | const auto* col_from = | 53 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 18 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 18 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 18 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 18 | const auto& vec_from = col_from->get_data(); | 64 | 18 | const auto* vec_from_data = vec_from.data(); | 65 | 18 | auto& vec_to = col_to->get_data(); | 66 | 18 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 18 | CastParameters params; | 69 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 18 | size_t size = vec_from.size(); | 71 | | | 72 | 18 | typename FromFieldType::NativeType scale_multiplier = | 73 | 18 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 680 | for (size_t i = 0; i < size; ++i) { | 75 | 662 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 662 | scale_multiplier, params); | 77 | 662 | } | 78 | | | 79 | 18 | block.get_by_position(result).column = std::move(col_to); | 80 | 18 | return Status::OK(); | 81 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 311 | for (size_t i = 0; i < size; ++i) { | 75 | 304 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 304 | scale_multiplier, params); | 77 | 304 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 311 | for (size_t i = 0; i < size; ++i) { | 75 | 304 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 304 | scale_multiplier, params); | 77 | 304 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 129 | for (size_t i = 0; i < size; ++i) { | 75 | 122 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 122 | scale_multiplier, params); | 77 | 122 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 7 | using FromFieldType = typename FromDataType::FieldType; | 51 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 7 | const auto* col_from = | 53 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 7 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 7 | const auto& vec_from = col_from->get_data(); | 64 | 7 | const auto* vec_from_data = vec_from.data(); | 65 | 7 | auto& vec_to = col_to->get_data(); | 66 | 7 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 7 | CastParameters params; | 69 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 7 | size_t size = vec_from.size(); | 71 | | | 72 | 7 | typename FromFieldType::NativeType scale_multiplier = | 73 | 7 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 129 | for (size_t i = 0; i < size; ++i) { | 75 | 122 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 122 | scale_multiplier, params); | 77 | 122 | } | 78 | | | 79 | 7 | block.get_by_position(result).column = std::move(col_to); | 80 | 7 | return Status::OK(); | 81 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 49 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 50 | 9 | using FromFieldType = typename FromDataType::FieldType; | 51 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 52 | 9 | const auto* col_from = | 53 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 54 | 9 | if (!col_from) { | 55 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 56 | 0 | type_to_string(FromDataType::PType), | 57 | 0 | named_from.column->get_name())); | 58 | 0 | } | 59 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 60 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 61 | | | 62 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 63 | 9 | const auto& vec_from = col_from->get_data(); | 64 | 9 | const auto* vec_from_data = vec_from.data(); | 65 | 9 | auto& vec_to = col_to->get_data(); | 66 | 9 | auto* vec_to_data = vec_to.data(); | 67 | | | 68 | 9 | CastParameters params; | 69 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 70 | 9 | size_t size = vec_from.size(); | 71 | | | 72 | 9 | typename FromFieldType::NativeType scale_multiplier = | 73 | 9 | DataTypeDecimal<FromFieldType::PType>::get_scale_multiplier(from_scale); | 74 | 521 | for (size_t i = 0; i < size; ++i) { | 75 | 512 | CastToFloat::_from_decimalv3(vec_from_data[i], from_scale, vec_to_data[i], | 76 | 512 | scale_multiplier, params); | 77 | 512 | } | 78 | | | 79 | 9 | block.get_by_position(result).column = std::move(col_to); | 80 | 9 | return Status::OK(); | 81 | 9 | } |
|
82 | | }; |
83 | | |
84 | | // cast date and datetime to float/double, will not overflow |
85 | | // only support in non-strict mode. strict mode it's illegal! |
86 | | template <typename FromDataType, typename ToDataType> |
87 | | requires(IsDataTypeFloat<ToDataType> && |
88 | | (IsDatelikeV1Types<FromDataType> || IsDatelikeV2Types<FromDataType> || |
89 | | std::is_same_v<FromDataType, DataTypeTimeV2>)) |
90 | | class CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType> : public CastToBase { |
91 | | public: |
92 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
93 | | uint32_t result, size_t input_rows_count, |
94 | 14 | const NullMap::value_type* null_map = nullptr) const override { |
95 | 14 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, |
96 | 14 | input_rows_count); |
97 | 14 | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 1 | input_rows_count); | 97 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 4 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 4 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 4 | input_rows_count); | 97 | 4 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 2 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 2 | input_rows_count); | 97 | 2 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 1 | input_rows_count); | 97 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 4 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 4 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 4 | input_rows_count); | 97 | 4 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 94 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 95 | 2 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 96 | 2 | input_rows_count); | 97 | 2 | } |
|
98 | | }; |
99 | | #include "common/compile_check_end.h" |
100 | | } // namespace doris |