diff options
author | galaxycrab <UgnineSirdis@ydb.tech> | 2023-01-20 18:16:29 +0300 |
---|---|---|
committer | galaxycrab <UgnineSirdis@ydb.tech> | 2023-01-20 18:16:29 +0300 |
commit | 39e1c3a18d8e756994fb4062c2afe4e2b548afe3 (patch) | |
tree | 4bf2a74c5d9942eb6b31ff33c50bfb59ef7cc965 | |
parent | c6a952a6e1eda08c6e1742ec1170691cec3670da (diff) | |
download | ydb-39e1c3a18d8e756994fb4062c2afe4e2b548afe3.tar.gz |
Validation in S3 source type annotation for the case when we have only partitioning columns
-rw-r--r-- | ydb/library/yql/providers/s3/provider/yql_s3_datasource_type_ann.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/ydb/library/yql/providers/s3/provider/yql_s3_datasource_type_ann.cpp b/ydb/library/yql/providers/s3/provider/yql_s3_datasource_type_ann.cpp index 07703efa8f..2b71b9d0cd 100644 --- a/ydb/library/yql/providers/s3/provider/yql_s3_datasource_type_ann.cpp +++ b/ydb/library/yql/providers/s3/provider/yql_s3_datasource_type_ann.cpp @@ -210,15 +210,11 @@ public: return TStatus::Error; } - if (TS3ReadObject::Match(input->Child(TS3ReadObject::idx_Object))) { + if (!TS3Object::Match(input->Child(TS3ReadObject::idx_Object))) { ctx.AddError(TIssue(ctx.GetPosition(input->Child(TS3ReadObject::idx_Object)->Pos()), "Expected S3 object.")); return TStatus::Error; } - if (!EnsureType(*input->Child(TS3ReadObject::idx_RowType), ctx)) { - return TStatus::Error; - } - const auto& rowTypeNode = *input->Child(TS3ReadObject::idx_RowType); if (!EnsureType(rowTypeNode, ctx)) { return TStatus::Error; @@ -229,6 +225,34 @@ public: return TStatus::Error; } + { + THashSet<TStringBuf> columns; + const TStructExprType* structRowType = rowType->Cast<TStructExprType>(); + for (const TItemExprType* item : structRowType->GetItems()) { + columns.emplace(item->GetName()); + } + + TS3Object s3Object(input->Child(TS3ReadObject::idx_Object)); + if (TMaybeNode<TExprBase> settings = s3Object.Settings()) { + for (auto& settingNode : settings.Raw()->ChildrenList()) { + const TStringBuf name = settingNode->Head().Content(); + if (name == "partitionedby"sv) { + for (size_t i = 1; i < settingNode->ChildrenSize(); ++i) { + const auto& column = settingNode->Child(i); + if (!EnsureAtom(*column, ctx)) { + return TStatus::Error; + } + columns.erase(column->Content()); + } + if (columns.empty()) { + ctx.AddError(TIssue(ctx.GetPosition(input->Pos()), "Table contains no columns except partitioning columns")); + return TStatus::Error; + } + } + } + } + } + input->SetTypeAnn(ctx.MakeType<TTupleExprType>(TTypeAnnotationNode::TListType{ input->Child(TS3ReadObject::idx_World)->GetTypeAnn(), ctx.MakeType<TListExprType>(rowType) |