@@ -32,6 +32,20 @@ struct MakeColumnFromConstant
3232 mr);
3333 return cudf::make_column_from_scalar (scalar, count, stream, mr);
3434 }
35+ else if constexpr (std::is_same_v<T, numeric::decimal32> || std::is_same_v<T, numeric::decimal64>)
36+ {
37+ auto type = expr.value .type ();
38+ if (type.id () != LogicalTypeId::DECIMAL ) {
39+ throw InternalException (" Invalid duckdb type for decimal constant: %d" , static_cast <int >(type.id ()));
40+ }
41+ // cudf decimal type uses negative scale
42+ auto scalar = cudf::fixed_point_scalar<T>(expr.value .GetValueUnsafe <typename T::rep>(),
43+ numeric::scale_type{-DecimalType::GetScale (type)},
44+ true ,
45+ stream,
46+ mr);
47+ return cudf::make_column_from_scalar (scalar, count, stream, mr);
48+ }
3549 else
3650 {
3751 auto scalar =
@@ -47,7 +61,8 @@ std::unique_ptr<cudf::column> GpuExpressionExecutor::Execute(const BoundConstant
4761 D_ASSERT (expr.value .type () == expr.return_type );
4862
4963 // In many cases, this column materialization is pruned away
50- switch (GpuExpressionState::GetCudfType (expr.return_type ).id ())
64+ auto cudf_type = GpuExpressionState::GetCudfType (expr.return_type );
65+ switch (cudf_type.id ())
5166 {
5267 case cudf::type_id::INT32 :
5368 return MakeColumnFromConstant<int32_t >::Do (expr, input_count, resource_ref, execution_stream);
@@ -61,8 +76,12 @@ std::unique_ptr<cudf::column> GpuExpressionExecutor::Execute(const BoundConstant
6176 return MakeColumnFromConstant<bool >::Do (expr, input_count, resource_ref, execution_stream);
6277 case cudf::type_id::STRING :
6378 return MakeColumnFromConstant<std::string>::Do (expr, input_count, resource_ref, execution_stream);
79+ case cudf::type_id::DECIMAL32 :
80+ return MakeColumnFromConstant<numeric::decimal32>::Do (expr, input_count, resource_ref, execution_stream);
81+ case cudf::type_id::DECIMAL64 :
82+ return MakeColumnFromConstant<numeric::decimal64>::Do (expr, input_count, resource_ref, execution_stream);
6483 default :
65- throw InternalException (" Execute[Constant]: Unknown type! " );
84+ throw InternalException (" Execute[Constant]: Unknown cudf type: %d " , static_cast < int >(cudf_type. id ()) );
6685 }
6786}
6887
0 commit comments