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 | | // cast bool, integer, float to double, will not overflow |
29 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
30 | | requires(IsDataTypeFloat<ToDataType> && IsDataTypeNumber<FromDataType>) |
31 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
32 | | public: |
33 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
34 | | uint32_t result, size_t input_rows_count, |
35 | 103 | const NullMap::value_type* null_map = nullptr) const override { |
36 | 103 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, |
37 | 103 | input_rows_count); |
38 | 103 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 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 | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 76 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 76 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 76 | input_rows_count); | 38 | 76 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 35 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 36 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 37 | 1 | input_rows_count); | 38 | 1 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh |
39 | | }; |
40 | | |
41 | | // cast decimal to float and double |
42 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
43 | | requires(IsDataTypeFloat<ToDataType> && IsDataTypeDecimal<FromDataType>) |
44 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
45 | | public: |
46 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
47 | | uint32_t result, size_t input_rows_count, |
48 | 186 | const NullMap::value_type* null_map = nullptr) const override { |
49 | 186 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
50 | 186 | const auto* col_from = |
51 | 186 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
52 | 186 | if (!col_from) { |
53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", |
54 | 0 | type_to_string(FromDataType::PType), |
55 | 0 | named_from.column->get_name())); |
56 | 0 | } |
57 | 186 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); |
58 | 186 | UInt32 from_scale = from_decimal_type.get_scale(); |
59 | | |
60 | 186 | auto col_to = ToDataType::ColumnType::create(input_rows_count); |
61 | 186 | const auto& vec_from = col_from->get_data(); |
62 | 186 | const auto* vec_from_data = vec_from.data(); |
63 | 186 | auto& vec_to = col_to->get_data(); |
64 | 186 | auto* vec_to_data = vec_to.data(); |
65 | | |
66 | 186 | CastParameters params; |
67 | 186 | params.is_strict = (CastMode == CastModeType::StrictMode); |
68 | 186 | size_t size = vec_from.size(); |
69 | 8.34k | for (size_t i = 0; i < size; ++i) { |
70 | 8.15k | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); |
71 | 8.15k | } |
72 | | |
73 | 186 | block.get_by_position(result).column = std::move(col_to); |
74 | 186 | return Status::OK(); |
75 | 186 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 7 | const auto* col_from = | 51 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 7 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 7 | const auto& vec_from = col_from->get_data(); | 62 | 7 | const auto* vec_from_data = vec_from.data(); | 63 | 7 | auto& vec_to = col_to->get_data(); | 64 | 7 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 7 | CastParameters params; | 67 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 7 | size_t size = vec_from.size(); | 69 | 311 | for (size_t i = 0; i < size; ++i) { | 70 | 304 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 304 | } | 72 | | | 73 | 7 | block.get_by_position(result).column = std::move(col_to); | 74 | 7 | return Status::OK(); | 75 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 7 | const auto* col_from = | 51 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 7 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 7 | const auto& vec_from = col_from->get_data(); | 62 | 7 | const auto* vec_from_data = vec_from.data(); | 63 | 7 | auto& vec_to = col_to->get_data(); | 64 | 7 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 7 | CastParameters params; | 67 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 7 | size_t size = vec_from.size(); | 69 | 311 | for (size_t i = 0; i < size; ++i) { | 70 | 304 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 304 | } | 72 | | | 73 | 7 | block.get_by_position(result).column = std::move(col_to); | 74 | 7 | return Status::OK(); | 75 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 8 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 8 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 8 | const auto* col_from = | 51 | 8 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 8 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 8 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 8 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 8 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 8 | const auto& vec_from = col_from->get_data(); | 62 | 8 | const auto* vec_from_data = vec_from.data(); | 63 | 8 | auto& vec_to = col_to->get_data(); | 64 | 8 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 8 | CastParameters params; | 67 | 8 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 8 | size_t size = vec_from.size(); | 69 | 132 | for (size_t i = 0; i < size; ++i) { | 70 | 124 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 124 | } | 72 | | | 73 | 8 | block.get_by_position(result).column = std::move(col_to); | 74 | 8 | return Status::OK(); | 75 | 8 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 8 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 8 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 8 | const auto* col_from = | 51 | 8 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 8 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 8 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 8 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 8 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 8 | const auto& vec_from = col_from->get_data(); | 62 | 8 | const auto* vec_from_data = vec_from.data(); | 63 | 8 | auto& vec_to = col_to->get_data(); | 64 | 8 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 8 | CastParameters params; | 67 | 8 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 8 | size_t size = vec_from.size(); | 69 | 132 | for (size_t i = 0; i < size; ++i) { | 70 | 124 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 124 | } | 72 | | | 73 | 8 | block.get_by_position(result).column = std::move(col_to); | 74 | 8 | return Status::OK(); | 75 | 8 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 18 | const auto* col_from = | 51 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 18 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 18 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 18 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 18 | const auto& vec_from = col_from->get_data(); | 62 | 18 | const auto* vec_from_data = vec_from.data(); | 63 | 18 | auto& vec_to = col_to->get_data(); | 64 | 18 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 18 | CastParameters params; | 67 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 18 | size_t size = vec_from.size(); | 69 | 680 | for (size_t i = 0; i < size; ++i) { | 70 | 662 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 662 | } | 72 | | | 73 | 18 | block.get_by_position(result).column = std::move(col_to); | 74 | 18 | return Status::OK(); | 75 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 18 | const auto* col_from = | 51 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 18 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 18 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 18 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 18 | const auto& vec_from = col_from->get_data(); | 62 | 18 | const auto* vec_from_data = vec_from.data(); | 63 | 18 | auto& vec_to = col_to->get_data(); | 64 | 18 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 18 | CastParameters params; | 67 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 18 | size_t size = vec_from.size(); | 69 | 680 | for (size_t i = 0; i < size; ++i) { | 70 | 662 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 662 | } | 72 | | | 73 | 18 | block.get_by_position(result).column = std::move(col_to); | 74 | 18 | return Status::OK(); | 75 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 7 | const auto* col_from = | 51 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 7 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 7 | const auto& vec_from = col_from->get_data(); | 62 | 7 | const auto* vec_from_data = vec_from.data(); | 63 | 7 | auto& vec_to = col_to->get_data(); | 64 | 7 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 7 | CastParameters params; | 67 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 7 | size_t size = vec_from.size(); | 69 | 311 | for (size_t i = 0; i < size; ++i) { | 70 | 304 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 304 | } | 72 | | | 73 | 7 | block.get_by_position(result).column = std::move(col_to); | 74 | 7 | return Status::OK(); | 75 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 7 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 7 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 7 | const auto* col_from = | 51 | 7 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 7 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 7 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 7 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 7 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 7 | const auto& vec_from = col_from->get_data(); | 62 | 7 | const auto* vec_from_data = vec_from.data(); | 63 | 7 | auto& vec_to = col_to->get_data(); | 64 | 7 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 7 | CastParameters params; | 67 | 7 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 7 | size_t size = vec_from.size(); | 69 | 311 | for (size_t i = 0; i < size; ++i) { | 70 | 304 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 304 | } | 72 | | | 73 | 7 | block.get_by_position(result).column = std::move(col_to); | 74 | 7 | return Status::OK(); | 75 | 7 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 8 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 8 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 8 | const auto* col_from = | 51 | 8 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 8 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 8 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 8 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 8 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 8 | const auto& vec_from = col_from->get_data(); | 62 | 8 | const auto* vec_from_data = vec_from.data(); | 63 | 8 | auto& vec_to = col_to->get_data(); | 64 | 8 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 8 | CastParameters params; | 67 | 8 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 8 | size_t size = vec_from.size(); | 69 | 132 | for (size_t i = 0; i < size; ++i) { | 70 | 124 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 124 | } | 72 | | | 73 | 8 | block.get_by_position(result).column = std::move(col_to); | 74 | 8 | return Status::OK(); | 75 | 8 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 8 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 8 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 8 | const auto* col_from = | 51 | 8 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 8 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 8 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 8 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 8 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 8 | const auto& vec_from = col_from->get_data(); | 62 | 8 | const auto* vec_from_data = vec_from.data(); | 63 | 8 | auto& vec_to = col_to->get_data(); | 64 | 8 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 8 | CastParameters params; | 67 | 8 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 8 | size_t size = vec_from.size(); | 69 | 132 | for (size_t i = 0; i < size; ++i) { | 70 | 124 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 124 | } | 72 | | | 73 | 8 | block.get_by_position(result).column = std::move(col_to); | 74 | 8 | return Status::OK(); | 75 | 8 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 48 | 9 | const NullMap::value_type* null_map = nullptr) const override { | 49 | 9 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 50 | 9 | const auto* col_from = | 51 | 9 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 52 | 9 | if (!col_from) { | 53 | 0 | return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}", | 54 | 0 | type_to_string(FromDataType::PType), | 55 | 0 | named_from.column->get_name())); | 56 | 0 | } | 57 | 9 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 58 | 9 | UInt32 from_scale = from_decimal_type.get_scale(); | 59 | | | 60 | 9 | auto col_to = ToDataType::ColumnType::create(input_rows_count); | 61 | 9 | const auto& vec_from = col_from->get_data(); | 62 | 9 | const auto* vec_from_data = vec_from.data(); | 63 | 9 | auto& vec_to = col_to->get_data(); | 64 | 9 | auto* vec_to_data = vec_to.data(); | 65 | | | 66 | 9 | CastParameters params; | 67 | 9 | params.is_strict = (CastMode == CastModeType::StrictMode); | 68 | 9 | size_t size = vec_from.size(); | 69 | 521 | for (size_t i = 0; i < size; ++i) { | 70 | 512 | CastToFloat::from_decimal(vec_from_data[i], from_scale, vec_to_data[i], params); | 71 | 512 | } | 72 | | | 73 | 9 | block.get_by_position(result).column = std::move(col_to); | 74 | 9 | return Status::OK(); | 75 | 9 | } |
|
76 | | }; |
77 | | |
78 | | // cast date and datetime to float/double, will not overflow |
79 | | // only support in non-strict mode. strict mode it's illegal! |
80 | | template <typename FromDataType, typename ToDataType> |
81 | | requires(IsDataTypeFloat<ToDataType> && |
82 | | (IsDatelikeV1Types<FromDataType> || IsDatelikeV2Types<FromDataType> || |
83 | | std::is_same_v<FromDataType, DataTypeTimeV2>)) |
84 | | class CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType> : public CastToBase { |
85 | | public: |
86 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
87 | | uint32_t result, size_t input_rows_count, |
88 | 14 | const NullMap::value_type* null_map = nullptr) const override { |
89 | 14 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, |
90 | 14 | input_rows_count); |
91 | 14 | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 1 | input_rows_count); | 91 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 4 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 4 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 4 | input_rows_count); | 91 | 4 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 2 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 2 | input_rows_count); | 91 | 2 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 1 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 1 | input_rows_count); | 91 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 4 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 4 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 4 | input_rows_count); | 91 | 4 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 88 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 89 | 2 | return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result, | 90 | 2 | input_rows_count); | 91 | 2 | } |
|
92 | | }; |
93 | | } // namespace doris |