@@ -282,6 +282,18 @@ bool ExtractSettingValue(const TExprNode& value, TStringBuf settingName, TString
282282
283283}
284284
285+ bool EnsureParquetTypeSupported (TPositionHandle position, const TTypeAnnotationNode* type, TExprContext& ctx, const IArrowResolver::TPtr& arrowResolver) {
286+ auto resolveStatus = arrowResolver->AreTypesSupported (ctx.GetPosition (position), { type }, ctx);
287+ YQL_ENSURE (resolveStatus != IArrowResolver::ERROR);
288+
289+ if (resolveStatus != IArrowResolver::OK) {
290+ ctx.AddError (TIssue (ctx.GetPosition (position), TStringBuilder () << " Type " << *type << " is not supported for parquet" ));
291+ return false ;
292+ }
293+
294+ return true ;
295+ }
296+
285297class TS3DataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
286298public:
287299 TS3DataSourceTypeAnnotationTransformer (TS3State::TPtr state)
@@ -407,7 +419,8 @@ class TS3DataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
407419 return TStatus::Error;
408420 }
409421
410- if (!TS3Object::Match (input->Child (TS3ReadObject::idx_Object))) {
422+ const auto & objectNode = input->Child (TS3ReadObject::idx_Object);
423+ if (!TS3Object::Match (objectNode)) {
411424 ctx.AddError (TIssue (ctx.GetPosition (input->Child (TS3ReadObject::idx_Object)->Pos ()), " Expected S3 object." ));
412425 return TStatus::Error;
413426 }
@@ -467,6 +480,19 @@ class TS3DataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
467480 return TStatus::Error;
468481 }
469482
483+ if (objectNode->Child (TS3Object::idx_Format)->Content () == " parquet" ) {
484+ YQL_ENSURE (State_->Types ->ArrowResolver );
485+ bool allTypesSupported = true ;
486+ for (const auto & item : rowType->Cast <TStructExprType>()->GetItems ()) {
487+ if (!EnsureParquetTypeSupported (input->Pos (), item->GetItemType (), ctx, State_->Types ->ArrowResolver )) {
488+ allTypesSupported = false ;
489+ }
490+ }
491+ if (!allTypesSupported) {
492+ return TStatus::Error;
493+ }
494+ }
495+
470496 input->SetTypeAnn (ctx.MakeType <TTupleExprType>(TTypeAnnotationNode::TListType{
471497 input->Child (TS3ReadObject::idx_World)->GetTypeAnn (),
472498 ctx.MakeType <TListExprType>(rowType)
0 commit comments