diff options
author | sabdenovch <sabdenovch@yandex-team.com> | 2024-06-03 23:33:09 +0300 |
---|---|---|
committer | sabdenovch <sabdenovch@yandex-team.com> | 2024-06-03 23:44:25 +0300 |
commit | 83e2d309d5d6613e344ca00a7d25fa473ceea74b (patch) | |
tree | b95750e6c0e17fcfbf121f7325d36e3a34d0cf49 | |
parent | ca99fc2f20163d67dbab313a7fdf6589d83ba220 (diff) | |
download | ydb-83e2d309d5d6613e344ca00a7d25fa473ceea74b.tar.gz |
YT-21669: Computed columns in Sort operation
c7ccedfc57e1b07e11c410c19f907ea8bda24dd3
-rw-r--r-- | yt/yt/client/table_client/check_schema_compatibility.cpp | 14 | ||||
-rw-r--r-- | yt/yt/client/table_client/check_schema_compatibility.h | 3 | ||||
-rw-r--r-- | yt/yt/client/table_client/schema.cpp | 11 |
3 files changed, 16 insertions, 12 deletions
diff --git a/yt/yt/client/table_client/check_schema_compatibility.cpp b/yt/yt/client/table_client/check_schema_compatibility.cpp index 6efdf606fc..f9b4c566fd 100644 --- a/yt/yt/client/table_client/check_schema_compatibility.cpp +++ b/yt/yt/client/table_client/check_schema_compatibility.cpp @@ -14,7 +14,8 @@ namespace NYT::NTableClient { std::pair<ESchemaCompatibility, TError> CheckTableSchemaCompatibilityImpl( const TTableSchema& inputSchema, const TTableSchema& outputSchema, - bool ignoreSortOrder) + bool ignoreSortOrder, + bool forbidExtraComputedColumns) { // If output schema is strict, check that input columns are subset of output columns. if (outputSchema.GetStrict()) { @@ -92,7 +93,7 @@ std::pair<ESchemaCompatibility, TError> CheckTableSchemaCompatibilityImpl( inputColumn->GetDiagnosticNameString()), }; } - } else if (outputColumn.Expression()) { + } else if (forbidExtraComputedColumns && outputColumn.Expression()) { return { ESchemaCompatibility::Incompatible, TError("Unexpected computed column %v in output schema", @@ -217,9 +218,14 @@ std::pair<ESchemaCompatibility, TError> CheckTableSchemaCompatibilityImpl( std::pair<ESchemaCompatibility, TError> CheckTableSchemaCompatibility( const TTableSchema& inputSchema, const TTableSchema& outputSchema, - bool ignoreSortOrder) + bool ignoreSortOrder, + bool forbidExtraComputedColumns) { - auto result = CheckTableSchemaCompatibilityImpl(inputSchema, outputSchema, ignoreSortOrder); + auto result = CheckTableSchemaCompatibilityImpl( + inputSchema, + outputSchema, + ignoreSortOrder, + forbidExtraComputedColumns); if (result.first != ESchemaCompatibility::FullyCompatible) { result.second = TError(NTableClient::EErrorCode::IncompatibleSchemas, "Table schemas are incompatible") << result.second diff --git a/yt/yt/client/table_client/check_schema_compatibility.h b/yt/yt/client/table_client/check_schema_compatibility.h index 0dac7cb20b..4fa260bb8d 100644 --- a/yt/yt/client/table_client/check_schema_compatibility.h +++ b/yt/yt/client/table_client/check_schema_compatibility.h @@ -15,7 +15,8 @@ namespace NYT::NTableClient { std::pair<ESchemaCompatibility, TError> CheckTableSchemaCompatibility( const TTableSchema& inputSchema, const TTableSchema& outputSchema, - bool ignoreSortOrder); + bool ignoreSortOrder, + bool forbidExtraComputedColumns = true); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/table_client/schema.cpp b/yt/yt/client/table_client/schema.cpp index 4b2ef241ec..d815e0d58e 100644 --- a/yt/yt/client/table_client/schema.cpp +++ b/yt/yt/client/table_client/schema.cpp @@ -924,19 +924,16 @@ TTableSchemaPtr TTableSchema::FromKeyColumns(const TKeyColumns& keyColumns) TTableSchemaPtr TTableSchema::FromSortColumns(const TSortColumns& sortColumns) { - TTableSchema schema; std::vector<TColumnSchema> columns; for (const auto& sortColumn : sortColumns) { columns.push_back( TColumnSchema(sortColumn.Name, ESimpleLogicalValueType::Any) .SetSortOrder(sortColumn.SortOrder)); } - schema.ColumnInfo_ = std::make_shared<const TColumnInfo>( - std::move(columns), - std::vector<TDeletedColumn>{}); - schema.KeyColumnCount_ = sortColumns.size(); - ValidateTableSchema(schema); - return New<TTableSchema>(std::move(schema)); + + auto schema = New<TTableSchema>(std::move(columns), /*strict*/ false); + ValidateTableSchema(*schema); + return schema; } TTableSchemaPtr TTableSchema::ToQuery() const |