Skip to content

default value has been disabled for column tables #16088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ydb/core/kqp/host/kqp_gateway_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,18 @@ bool FillColumnTableSchema(NKikimrSchemeOp::TColumnTableSchema& schema, const T&
auto columnIt = metadata.Columns.find(name);
Y_ENSURE(columnIt != metadata.Columns.end());

if (columnIt->second.IsDefaultFromSequence()) {
code = Ydb::StatusIds::BAD_REQUEST;
error = TStringBuilder() << "Default value from sequence specified for column `" << columnIt->second.Name << "` is not supported in cases of column tables";
return false;
}

if (columnIt->second.IsDefaultFromLiteral()) {
code = Ydb::StatusIds::BAD_REQUEST;
error = TStringBuilder() << "Default value from literal specified for column `" << columnIt->second.Name << "` is not supported in cases of column tables";
return false;
}

NKikimrSchemeOp::TOlapColumnDescription& columnDesc = *schema.AddColumns();
columnDesc.SetName(columnIt->second.Name);
columnDesc.SetType(columnIt->second.Type);
Expand Down
21 changes: 21 additions & 0 deletions ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3333,5 +3333,26 @@ Y_UNIT_TEST_SUITE(KqpOlap) {

testHelper.ReadData("SELECT COUNT(*) FROM `/Root/ColumnTableTest` WHERE time > CurrentUtcTimestamp()", "[[1u]]");
}

Y_UNIT_TEST(WithDefaultValue) {
std::unique_ptr<TKikimrRunner> Kikimr;
auto settings = TKikimrSettings().SetWithSampleTables(false);
auto kikimr = std::make_unique<TKikimrRunner>(settings);
Tests::NCommon::TLoggerInit(*kikimr).Initialize();
auto queryClient = kikimr->GetQueryClient();
{
auto result = queryClient.ExecuteQuery(R"(
CREATE TABLE Test (
Id Uint32 not null,
Value String DEFAULT "aba",
PRIMARY KEY (Id)
) WITH (
STORE = COLUMN
);
)", NQuery::TTxControl::NoTx()).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), NYdb::EStatus::GENERIC_ERROR);
UNIT_ASSERT_STRING_CONTAINS_C(result.GetIssues().ToString(), "Default value from literal specified for column `Value` is not supported in cases of column tables", result.GetIssues().ToString());
}
}
}
}
12 changes: 12 additions & 0 deletions ydb/core/ydb_convert/table_description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,18 @@ bool FillColumnDescriptionImpl(TColumnTable& out, const google::protobuf::Repeat
if (!column.Getfamily().empty()) {
columnDesc->SetColumnFamilyName(column.Getfamily());
}

if (column.has_from_literal()) {
status = Ydb::StatusIds::BAD_REQUEST;
error = TStringBuilder() << "Default value from literal specified for column `" << column.name() << "` is not supported in cases of column tables";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы упростил до Default values are not supported in column tables

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда может быть не понятно в какой колонке проблема. Тут могут использовать orm и прочие инструменты вокруг и в этом случае может быть сложно раздебажить, а в какой колоноке вообще default values появились

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И еще они двух видов бывают, наверное для дебага пользователю полезно получить информацию sequence это или literal

return false;
}

if (column.has_from_sequence()) {
status = Ydb::StatusIds::BAD_REQUEST;
error = TStringBuilder() << "Default value from sequence specified for column `" << column.name() << "` is not supported in cases of column tables";
return false;
}
}

return true;
Expand Down
Loading