| 901 | } |
| 902 | |
| 903 | std::shared_ptr<CastFunction> GetCastToDecimal64() { |
| 904 | OutputType sig_out_ty(ResolveOutputFromOptions); |
| 905 | |
| 906 | auto func = std::make_shared<CastFunction>("cast_decimal64", Type::DECIMAL64); |
| 907 | AddCommonCasts(Type::DECIMAL64, sig_out_ty, func.get()); |
| 908 | |
| 909 | // Cast from floating point |
| 910 | DCHECK_OK(func->AddKernel(Type::FLOAT, {float32()}, sig_out_ty, |
| 911 | CastFunctor<Decimal64Type, FloatType>::Exec)); |
| 912 | DCHECK_OK(func->AddKernel(Type::DOUBLE, {float64()}, sig_out_ty, |
| 913 | CastFunctor<Decimal64Type, DoubleType>::Exec)); |
| 914 | |
| 915 | // Cast from integer |
| 916 | for (const std::shared_ptr<DataType>& in_ty : IntTypes()) { |
| 917 | auto exec = GenerateInteger<CastFunctor, Decimal64Type>(in_ty->id()); |
| 918 | DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, sig_out_ty, std::move(exec))); |
| 919 | } |
| 920 | |
| 921 | // Cast from other strings |
| 922 | for (const std::shared_ptr<DataType>& in_ty : BaseBinaryTypes()) { |
| 923 | auto exec = GenerateVarBinaryBase<CastFunctor, Decimal64Type>(in_ty->id()); |
| 924 | DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, sig_out_ty, std::move(exec))); |
| 925 | } |
| 926 | for (const std::shared_ptr<DataType>& in_ty : BinaryViewTypes()) { |
| 927 | auto exec = GenerateVarBinaryViewBase<CastFunctor, Decimal64Type>(in_ty->id()); |
| 928 | DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, sig_out_ty, std::move(exec))); |
| 929 | } |
| 930 | |
| 931 | // Cast from other decimal |
| 932 | auto exec = CastFunctor<Decimal64Type, Decimal32Type>::Exec; |
| 933 | DCHECK_OK( |
| 934 | func->AddKernel(Type::DECIMAL32, {InputType(Type::DECIMAL32)}, sig_out_ty, exec)); |
| 935 | exec = CastFunctor<Decimal64Type, Decimal64Type>::Exec; |
| 936 | DCHECK_OK( |
| 937 | func->AddKernel(Type::DECIMAL64, {InputType(Type::DECIMAL64)}, sig_out_ty, exec)); |
| 938 | exec = CastFunctor<Decimal64Type, Decimal128Type>::Exec; |
| 939 | DCHECK_OK( |
| 940 | func->AddKernel(Type::DECIMAL128, {InputType(Type::DECIMAL128)}, sig_out_ty, exec)); |
| 941 | exec = CastFunctor<Decimal64Type, Decimal256Type>::Exec; |
| 942 | DCHECK_OK( |
| 943 | func->AddKernel(Type::DECIMAL256, {InputType(Type::DECIMAL256)}, sig_out_ty, exec)); |
| 944 | return func; |
| 945 | } |
| 946 | |
| 947 | std::shared_ptr<CastFunction> GetCastToDecimal128() { |
| 948 | OutputType sig_out_ty(ResolveOutputFromOptions); |
no test coverage detected