@@ -1957,6 +1957,8 @@ NUdf::TUnboxedValuePod ConvertToPgValue(NUdf::TUnboxedValuePod value, TMaybe<NUd
1957
1957
return ScalarDatumToPod (Int64GetDatum (value.Get <i64 >()));
1958
1958
case NUdf::EDataSlot::Uint64:
1959
1959
return PointerDatumToPod (NumericGetDatum (Uint64ToPgNumeric (value.Get <ui64>())));
1960
+ case NUdf::EDataSlot::DyNumber:
1961
+ return PointerDatumToPod (NumericGetDatum (DyNumberToPgNumeric (value)));
1960
1962
case NUdf::EDataSlot::Float:
1961
1963
return ScalarDatumToPod (Float4GetDatum (value.Get <float >()));
1962
1964
case NUdf::EDataSlot::Double:
@@ -2182,9 +2184,10 @@ template <NUdf::EDataSlot Slot>
2182
2184
class TToPg : public TMutableComputationNode <TToPg<Slot>> {
2183
2185
typedef TMutableComputationNode<TToPg<Slot>> TBaseComputation;
2184
2186
public:
2185
- TToPg (TComputationMutables& mutables, IComputationNode* arg)
2187
+ TToPg (TComputationMutables& mutables, IComputationNode* arg, TDataType* argType )
2186
2188
: TBaseComputation(mutables)
2187
2189
, Arg(arg)
2190
+ , ArgType(argType)
2188
2191
{
2189
2192
}
2190
2193
@@ -2194,7 +2197,13 @@ class TToPg : public TMutableComputationNode<TToPg<Slot>> {
2194
2197
return value.Release ();
2195
2198
}
2196
2199
2197
- return ConvertToPgValue<Slot>(value);
2200
+ if constexpr (Slot == NUdf::EDataSlot::Decimal) {
2201
+ auto decimalType = static_cast <TDataDecimalType*>(ArgType);
2202
+ return PointerDatumToPod (NumericGetDatum (DecimalToPgNumeric (value,
2203
+ decimalType->GetParams ().first , decimalType->GetParams ().second )));
2204
+ } else {
2205
+ return ConvertToPgValue<Slot>(value);
2206
+ }
2198
2207
}
2199
2208
2200
2209
private:
@@ -2203,6 +2212,7 @@ class TToPg : public TMutableComputationNode<TToPg<Slot>> {
2203
2212
}
2204
2213
2205
2214
IComputationNode* const Arg;
2215
+ TDataType* ArgType;
2206
2216
};
2207
2217
2208
2218
class TPgArray : public TMutableComputationNode <TPgArray> {
@@ -3159,64 +3169,69 @@ TComputationNodeFactory GetPgFactory() {
3159
3169
argType = AS_TYPE (TOptionalType, argType)->GetItemType ();
3160
3170
}
3161
3171
3162
- auto sourceDataSlot = AS_TYPE (TDataType, argType)->GetDataSlot ();
3172
+ auto dataType = AS_TYPE (TDataType, argType);
3173
+ auto sourceDataSlot = dataType->GetDataSlot ();
3163
3174
switch (*sourceDataSlot) {
3164
3175
case NUdf::EDataSlot::Bool:
3165
- return new TToPg<NUdf::EDataSlot::Bool>(ctx.Mutables , arg);
3176
+ return new TToPg<NUdf::EDataSlot::Bool>(ctx.Mutables , arg, dataType );
3166
3177
case NUdf::EDataSlot::Int8:
3167
- return new TToPg<NUdf::EDataSlot::Int8>(ctx.Mutables , arg);
3178
+ return new TToPg<NUdf::EDataSlot::Int8>(ctx.Mutables , arg, dataType );
3168
3179
case NUdf::EDataSlot::Uint8:
3169
- return new TToPg<NUdf::EDataSlot::Uint8>(ctx.Mutables , arg);
3180
+ return new TToPg<NUdf::EDataSlot::Uint8>(ctx.Mutables , arg, dataType);
3170
3181
case NUdf::EDataSlot::Int16:
3171
- return new TToPg<NUdf::EDataSlot::Int16>(ctx.Mutables , arg);
3182
+ return new TToPg<NUdf::EDataSlot::Int16>(ctx.Mutables , arg, dataType );
3172
3183
case NUdf::EDataSlot::Uint16:
3173
- return new TToPg<NUdf::EDataSlot::Uint16>(ctx.Mutables , arg);
3184
+ return new TToPg<NUdf::EDataSlot::Uint16>(ctx.Mutables , arg, dataType);
3174
3185
case NUdf::EDataSlot::Int32:
3175
- return new TToPg<NUdf::EDataSlot::Int32>(ctx.Mutables , arg);
3186
+ return new TToPg<NUdf::EDataSlot::Int32>(ctx.Mutables , arg, dataType );
3176
3187
case NUdf::EDataSlot::Uint32:
3177
- return new TToPg<NUdf::EDataSlot::Uint32>(ctx.Mutables , arg);
3188
+ return new TToPg<NUdf::EDataSlot::Uint32>(ctx.Mutables , arg, dataType );
3178
3189
case NUdf::EDataSlot::Int64:
3179
- return new TToPg<NUdf::EDataSlot::Int64>(ctx.Mutables , arg);
3190
+ return new TToPg<NUdf::EDataSlot::Int64>(ctx.Mutables , arg, dataType );
3180
3191
case NUdf::EDataSlot::Uint64:
3181
- return new TToPg<NUdf::EDataSlot::Uint64>(ctx.Mutables , arg);
3192
+ return new TToPg<NUdf::EDataSlot::Uint64>(ctx.Mutables , arg, dataType );
3182
3193
case NUdf::EDataSlot::Float:
3183
- return new TToPg<NUdf::EDataSlot::Float>(ctx.Mutables , arg);
3194
+ return new TToPg<NUdf::EDataSlot::Float>(ctx.Mutables , arg, dataType );
3184
3195
case NUdf::EDataSlot::Double:
3185
- return new TToPg<NUdf::EDataSlot::Double>(ctx.Mutables , arg);
3196
+ return new TToPg<NUdf::EDataSlot::Double>(ctx.Mutables , arg, dataType );
3186
3197
case NUdf::EDataSlot::Utf8:
3187
- return new TToPg<NUdf::EDataSlot::Utf8>(ctx.Mutables , arg);
3198
+ return new TToPg<NUdf::EDataSlot::Utf8>(ctx.Mutables , arg, dataType );
3188
3199
case NUdf::EDataSlot::String:
3189
- return new TToPg<NUdf::EDataSlot::String>(ctx.Mutables , arg);
3200
+ return new TToPg<NUdf::EDataSlot::String>(ctx.Mutables , arg, dataType );
3190
3201
case NUdf::EDataSlot::Date:
3191
- return new TToPg<NUdf::EDataSlot::Date>(ctx.Mutables , arg);
3202
+ return new TToPg<NUdf::EDataSlot::Date>(ctx.Mutables , arg, dataType );
3192
3203
case NUdf::EDataSlot::Datetime:
3193
- return new TToPg<NUdf::EDataSlot::Datetime>(ctx.Mutables , arg);
3204
+ return new TToPg<NUdf::EDataSlot::Datetime>(ctx.Mutables , arg, dataType );
3194
3205
case NUdf::EDataSlot::Timestamp:
3195
- return new TToPg<NUdf::EDataSlot::Timestamp>(ctx.Mutables , arg);
3206
+ return new TToPg<NUdf::EDataSlot::Timestamp>(ctx.Mutables , arg, dataType );
3196
3207
case NUdf::EDataSlot::Interval:
3197
- return new TToPg<NUdf::EDataSlot::Interval>(ctx.Mutables , arg);
3208
+ return new TToPg<NUdf::EDataSlot::Interval>(ctx.Mutables , arg, dataType );
3198
3209
case NUdf::EDataSlot::TzDate:
3199
- return new TToPg<NUdf::EDataSlot::TzDate>(ctx.Mutables , arg);
3210
+ return new TToPg<NUdf::EDataSlot::TzDate>(ctx.Mutables , arg, dataType );
3200
3211
case NUdf::EDataSlot::TzDatetime:
3201
- return new TToPg<NUdf::EDataSlot::TzDatetime>(ctx.Mutables , arg);
3212
+ return new TToPg<NUdf::EDataSlot::TzDatetime>(ctx.Mutables , arg, dataType );
3202
3213
case NUdf::EDataSlot::TzTimestamp:
3203
- return new TToPg<NUdf::EDataSlot::TzTimestamp>(ctx.Mutables , arg);
3214
+ return new TToPg<NUdf::EDataSlot::TzTimestamp>(ctx.Mutables , arg, dataType );
3204
3215
case NUdf::EDataSlot::Date32:
3205
- return new TToPg<NUdf::EDataSlot::Date32>(ctx.Mutables , arg);
3216
+ return new TToPg<NUdf::EDataSlot::Date32>(ctx.Mutables , arg, dataType );
3206
3217
case NUdf::EDataSlot::Datetime64:
3207
- return new TToPg<NUdf::EDataSlot::Datetime64>(ctx.Mutables , arg);
3218
+ return new TToPg<NUdf::EDataSlot::Datetime64>(ctx.Mutables , arg, dataType );
3208
3219
case NUdf::EDataSlot::Timestamp64:
3209
- return new TToPg<NUdf::EDataSlot::Timestamp64>(ctx.Mutables , arg);
3220
+ return new TToPg<NUdf::EDataSlot::Timestamp64>(ctx.Mutables , arg, dataType );
3210
3221
case NUdf::EDataSlot::Interval64:
3211
- return new TToPg<NUdf::EDataSlot::Interval64>(ctx.Mutables , arg);
3222
+ return new TToPg<NUdf::EDataSlot::Interval64>(ctx.Mutables , arg, dataType );
3212
3223
case NUdf::EDataSlot::Uuid:
3213
- return new TToPg<NUdf::EDataSlot::Uuid>(ctx.Mutables , arg);
3224
+ return new TToPg<NUdf::EDataSlot::Uuid>(ctx.Mutables , arg, dataType );
3214
3225
case NUdf::EDataSlot::Yson:
3215
- return new TToPg<NUdf::EDataSlot::Yson>(ctx.Mutables , arg);
3226
+ return new TToPg<NUdf::EDataSlot::Yson>(ctx.Mutables , arg, dataType );
3216
3227
case NUdf::EDataSlot::Json:
3217
- return new TToPg<NUdf::EDataSlot::Json>(ctx.Mutables , arg);
3228
+ return new TToPg<NUdf::EDataSlot::Json>(ctx.Mutables , arg, dataType );
3218
3229
case NUdf::EDataSlot::JsonDocument:
3219
- return new TToPg<NUdf::EDataSlot::JsonDocument>(ctx.Mutables , arg);
3230
+ return new TToPg<NUdf::EDataSlot::JsonDocument>(ctx.Mutables , arg, dataType);
3231
+ case NUdf::EDataSlot::Decimal:
3232
+ return new TToPg<NUdf::EDataSlot::Decimal>(ctx.Mutables , arg, dataType);
3233
+ case NUdf::EDataSlot::DyNumber:
3234
+ return new TToPg<NUdf::EDataSlot::DyNumber>(ctx.Mutables , arg, dataType);
3220
3235
default :
3221
3236
ythrow yexception () << " Unsupported type: " << NUdf::GetDataTypeInfo (*sourceDataSlot).Name ;
3222
3237
}
0 commit comments