@@ -235,12 +235,8 @@ void FillColumns(const TContainer& columns, const TKikimrTableMetadata& tableMet
235235 }
236236}
237237
238- void FillNothing (TCoNothing expr, NKqpProto::TKqpPhyLiteralValue& value) {
239- auto * typeann = expr.Raw ()->GetTypeAnn ();
240- YQL_ENSURE (typeann->GetKind () == ETypeAnnotationKind::Optional);
241- typeann = typeann->Cast <TOptionalExprType>()->GetItemType ();
242- YQL_ENSURE (typeann->GetKind () == ETypeAnnotationKind::Data);
243- auto slot = typeann->Cast <TDataExprType>()->GetSlot ();
238+ void FillNothingData (const TDataExprType& dataType, NKqpProto::TKqpPhyLiteralValue& value) {
239+ auto slot = dataType.GetSlot ();
244240 auto typeId = NKikimr::NUdf::GetDataTypeInfo (slot).TypeId ;
245241
246242 YQL_ENSURE (NKikimr::NScheme::NTypeIds::IsYqlType (typeId) &&
@@ -253,16 +249,43 @@ void FillNothing(TCoNothing expr, NKqpProto::TKqpPhyLiteralValue& value) {
253249 toFill->MutableData ()->SetScheme (typeId);
254250
255251 if (slot == EDataSlot::Decimal) {
256- const auto paramsDataType = typeann-> Cast <TDataExprParamsType>();
257- auto precision = FromString<ui8>(paramsDataType-> GetParamOne ());
258- auto scale = FromString<ui8>(paramsDataType-> GetParamTwo ());
252+ const auto & paramsDataType = *dataType. Cast <TDataExprParamsType>();
253+ auto precision = FromString<ui8>(paramsDataType. GetParamOne ());
254+ auto scale = FromString<ui8>(paramsDataType. GetParamTwo ());
259255 toFill->MutableData ()->MutableDecimalParams ()->SetPrecision (precision);
260256 toFill->MutableData ()->MutableDecimalParams ()->SetScale (scale);
261257 }
262258
263259 value.MutableValue ()->SetNullFlagValue (::google::protobuf::NullValue::NULL_VALUE);
264260}
265261
262+ void FillNothingPg (const TPgExprType& pgType, NKqpProto::TKqpPhyLiteralValue& value) {
263+ value.MutableType ()->SetKind (NKikimrMiniKQL::Pg);
264+ value.MutableType ()->MutablePg ()->Setoid (pgType.GetId ());
265+
266+ value.MutableValue ()->SetNullFlagValue (::google::protobuf::NullValue::NULL_VALUE);
267+ }
268+
269+ void FillNothing (TCoNothing expr, NKqpProto::TKqpPhyLiteralValue& value) {
270+ auto * typeann = expr.Raw ()->GetTypeAnn ();
271+ switch (typeann->GetKind ()) {
272+ case ETypeAnnotationKind::Optional: {
273+ typeann = typeann->Cast <TOptionalExprType>()->GetItemType ();
274+ YQL_ENSURE (
275+ typeann->GetKind () == ETypeAnnotationKind::Data,
276+ " Unexpected type in Nothing.Optional: " << typeann->GetKind ());
277+ FillNothingData (*typeann->Cast <TDataExprType>(), value);
278+ return ;
279+ }
280+ case ETypeAnnotationKind::Pg: {
281+ FillNothingPg (*typeann->Cast <TPgExprType>(), value);
282+ return ;
283+ }
284+ default :
285+ YQL_ENSURE (false , " Unexpected type in Nothing: " << typeann->GetKind ());
286+ }
287+ }
288+
266289void FillKeyBound (const TVarArgCallable<TExprBase>& bound, NKqpProto::TKqpPhyKeyBound& boundProto) {
267290 if (bound.Maybe <TKqlKeyInc>()) {
268291 boundProto.SetIsInclusive (true );
@@ -286,6 +309,8 @@ void FillKeyBound(const TVarArgCallable<TExprBase>& bound, NKqpProto::TKqpPhyKey
286309 paramElementProto.SetElementIndex (FromString<ui32>(key.Cast <TCoNth>().Index ().Value ()));
287310 } else if (auto maybeLiteral = key.Maybe <TCoDataCtor>()) {
288311 FillLiteralProto (maybeLiteral.Cast (), *protoValue.MutableLiteralValue ());
312+ } else if (auto maybePgLiteral = key.Maybe <TCoPgConst>()) {
313+ FillLiteralProto (maybePgLiteral.Cast (), *protoValue.MutableLiteralValue ());
289314 } else if (auto maybeNull = key.Maybe <TCoNothing>()) {
290315 FillNothing (maybeNull.Cast (), *protoValue.MutableLiteralValue ());
291316 } else {
0 commit comments