From 6c8c1fc3ad058e8d3cd74129a748263f32895c69 Mon Sep 17 00:00:00 2001 From: Aleksei Pleshakov Date: Fri, 5 Apr 2024 16:44:42 +0000 Subject: [PATCH] KIKIMR-18545: do not set not_null for default values --- ydb/core/tx/schemeshard/ut_export/ut_export.cpp | 2 -- ydb/core/ydb_convert/table_description.cpp | 10 ++++++---- ydb/services/ydb/ydb_ut.cpp | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp index 0408d35f5141..67d54ae2ec4f 100644 --- a/ydb/core/tx/schemeshard/ut_export/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export/ut_export.cpp @@ -365,7 +365,6 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { } } } - not_null: false from_literal { type { optional_type { @@ -390,7 +389,6 @@ columns { } } } - not_null: false from_literal { type { optional_type { diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index fc8a40a8e8ad..a3e9eccf61d9 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -370,13 +370,15 @@ static Ydb::Type* AddColumn(Ydb::Table::ColumnMeta* newColumn, const TColumn& co pg->set_oid(NPg::PgTypeIdFromTypeDesc(typeDesc)); pg->set_typlen(0); pg->set_typmod(0); + if (column.GetNotNull()) { + newColumn->set_not_null(column.GetNotNull()); + } } else { NYql::NProto::TypeIds protoType; if (!NYql::NProto::TypeIds_Parse(column.GetType(), &protoType)) { throw NYql::TErrorException(NKikimrIssues::TIssuesIds::DEFAULT_ERROR) << "Got invalid type: " << column.GetType() << " for column: " << column.GetName(); } - if (column.GetNotNull()) { columnType = newColumn->mutable_type(); } else { @@ -392,7 +394,6 @@ static Ydb::Type* AddColumn(Ydb::Table::ColumnMeta* newColumn, const TColumn& co NMiniKQL::ExportPrimitiveTypeToProto(protoType, *columnType); } } - newColumn->set_not_null(column.GetNotNull()); return columnType; } @@ -410,13 +411,15 @@ Ydb::Type* AddColumn(Ydb::Table::ColumnMeta pg->set_oid(NPg::PgTypeIdFromTypeDesc(typeDesc)); pg->set_typlen(0); pg->set_typmod(0); + if (column.GetNotNull()) { + newColumn->set_not_null(column.GetNotNull()); + } } else { NYql::NProto::TypeIds protoType; if (!NYql::NProto::TypeIds_Parse(column.GetType(), &protoType)) { throw NYql::TErrorException(NKikimrIssues::TIssuesIds::DEFAULT_ERROR) << "Got invalid type: " << column.GetType() << " for column: " << column.GetName(); } - if (column.GetNotNull()) { columnType = newColumn->mutable_type(); } else { @@ -432,7 +435,6 @@ Ydb::Type* AddColumn(Ydb::Table::ColumnMeta NMiniKQL::ExportPrimitiveTypeToProto(protoType, *columnType); } } - newColumn->set_not_null(column.GetNotNull()); switch (column.GetDefaultValueCase()) { case NKikimrSchemeOp::TColumnDescription::kDefaultFromLiteral: { auto fromLiteral = newColumn->mutable_from_literal(); diff --git a/ydb/services/ydb/ydb_ut.cpp b/ydb/services/ydb/ydb_ut.cpp index dee74daf8e28..2ddc36dd71c2 100644 --- a/ydb/services/ydb/ydb_ut.cpp +++ b/ydb/services/ydb/ydb_ut.cpp @@ -1268,7 +1268,6 @@ columns { } } } - not_null: false } columns { name: "Value" @@ -1279,7 +1278,6 @@ columns { } } } - not_null: false } primary_key: "Key" partitioning_settings { @@ -1607,7 +1605,6 @@ columns { } } } - not_null: false } columns { name: "IValue" @@ -1618,7 +1615,6 @@ columns { } } } - not_null: false } primary_key: "Key" indexes {