summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yt/yt/client/table_client/check_schema_compatibility.cpp14
-rw-r--r--yt/yt/client/table_client/check_schema_compatibility.h3
-rw-r--r--yt/yt/client/table_client/schema.cpp11
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 6efdf606fc4..f9b4c566fd4 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 0dac7cb20b3..4fa260bb8d4 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 4b2ef241ecc..d815e0d58ea 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