MCPcopy Create free account
hub / github.com/apache/arrow / GetNumericCasts

Function GetNumericCasts

cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc:1083–1135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081} // namespace
1082
1083std::vector<std::shared_ptr<CastFunction>> GetNumericCasts() {
1084 std::vector<std::shared_ptr<CastFunction>> functions;
1085
1086 // Make a cast to null that does not do much. Not sure why we need to be able
1087 // to cast from dict<null> -> null but there are unit tests for it
1088 auto cast_null = std::make_shared<CastFunction>("cast_null", Type::NA);
1089 DCHECK_OK(cast_null->AddKernel(Type::DICTIONARY, {InputType(Type::DICTIONARY)}, null(),
1090 OutputAllNull));
1091 // Explicitly allow casting extension type with null backing array to null
1092 DCHECK_OK(cast_null->AddKernel(
1093 Type::EXTENSION, {InputType(std::make_shared<NullExtensionTypeMatcher>())}, null(),
1094 OutputAllNull));
1095 functions.push_back(cast_null);
1096
1097 functions.push_back(GetCastToInteger<Int8Type>("cast_int8"));
1098 functions.push_back(GetCastToInteger<Int16Type>("cast_int16"));
1099
1100 auto cast_int32 = GetCastToInteger<Int32Type>("cast_int32");
1101 // Convert DATE32 or TIME32 to INT32 zero copy
1102 AddZeroCopyCast(Type::DATE32, date32(), int32(), cast_int32.get());
1103 AddZeroCopyCast(Type::TIME32, InputType(Type::TIME32), int32(), cast_int32.get());
1104 functions.push_back(cast_int32);
1105
1106 auto cast_int64 = GetCastToInteger<Int64Type>("cast_int64");
1107 // Convert DATE64, DURATION, TIMESTAMP, TIME64 to INT64 zero copy
1108 AddZeroCopyCast(Type::DATE64, InputType(Type::DATE64), int64(), cast_int64.get());
1109 AddZeroCopyCast(Type::DURATION, InputType(Type::DURATION), int64(), cast_int64.get());
1110 AddZeroCopyCast(Type::TIMESTAMP, InputType(Type::TIMESTAMP), int64(), cast_int64.get());
1111 AddZeroCopyCast(Type::TIME64, InputType(Type::TIME64), int64(), cast_int64.get());
1112 functions.push_back(cast_int64);
1113
1114 functions.push_back(GetCastToInteger<UInt8Type>("cast_uint8"));
1115 functions.push_back(GetCastToInteger<UInt16Type>("cast_uint16"));
1116 functions.push_back(GetCastToInteger<UInt32Type>("cast_uint32"));
1117 functions.push_back(GetCastToInteger<UInt64Type>("cast_uint64"));
1118
1119 // HalfFloat is a bit brain-damaged for now
1120 auto cast_half_float = GetCastToHalfFloat();
1121 functions.push_back(cast_half_float);
1122
1123 auto cast_float = GetCastToFloating<FloatType>("cast_float");
1124 functions.push_back(cast_float);
1125
1126 auto cast_double = GetCastToFloating<DoubleType>("cast_double");
1127 functions.push_back(cast_double);
1128
1129 functions.push_back(GetCastToDecimal32());
1130 functions.push_back(GetCastToDecimal64());
1131 functions.push_back(GetCastToDecimal128());
1132 functions.push_back(GetCastToDecimal256());
1133
1134 return functions;
1135}
1136
1137} // namespace internal
1138} // namespace compute

Callers 1

InitCastTableFunction · 0.85

Calls 10

InputTypeFunction · 0.85
AddZeroCopyCastFunction · 0.85
GetCastToHalfFloatFunction · 0.85
GetCastToDecimal32Function · 0.85
GetCastToDecimal64Function · 0.85
GetCastToDecimal128Function · 0.85
GetCastToDecimal256Function · 0.85
push_backMethod · 0.80
AddKernelMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected