Skip to content

Commit 663d308

Browse files
authored
Remove old restriction: keys with Uint8 column values >127 are currently prohibited (#11886)
1 parent 198242d commit 663d308

File tree

7 files changed

+59
-37
lines changed

7 files changed

+59
-37
lines changed

ydb/core/engine/mkql_engine_flat.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,6 @@ class TEngineFlat : public IEngineFlat {
577577
AddError("Validate", __LINE__, "Bad shard program: key size is greater that specified in schema");
578578
return false;
579579
}
580-
for (size_t i = 0; i < desc.Range.From.size(); ++i) {
581-
if (desc.KeyColumnTypes[i].GetTypeId() != NScheme::NTypeIds::Uint8)
582-
continue;
583-
const TCell& c = desc.Range.From[i];
584-
if (!c.IsNull() && c.AsValue<ui8>() > 127) {
585-
AddError("Validate", __LINE__, "Bad shard program: keys with Uint8 column values >127 are currently prohibited");
586-
return false;
587-
}
588-
}
589580
}
590581
return true;
591582
}

ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5286,6 +5286,64 @@ R"([[#;#;["Primary1"];[41u]];[["Secondary2"];[2u];["Primary2"];[42u]];[["Seconda
52865286
UNIT_ASSERT_VALUES_EQUAL(reads[0]["columns"].GetArraySafe().size(), 1);
52875287
}
52885288
}
5289+
5290+
Y_UNIT_TEST(Uint8Index) {
5291+
TKikimrRunner kikimr;
5292+
auto db = kikimr.GetTableClient();
5293+
auto session = db.CreateSession().GetValueSync().GetSession();
5294+
5295+
{
5296+
const TString createTableSql = R"(CREATE TABLE `/Root/table` (
5297+
key Uint8,
5298+
value Uint8,
5299+
PRIMARY KEY (key)
5300+
);)";
5301+
5302+
auto result = session.ExecuteSchemeQuery(createTableSql).GetValueSync();
5303+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5304+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS);
5305+
}
5306+
5307+
{
5308+
const TString upsertSql(Q_(R"(
5309+
UPSERT INTO `/Root/table` (key, value) VALUES
5310+
(0, 1),
5311+
(10, 11),
5312+
(100, 101),
5313+
(200, 201);
5314+
)"));
5315+
5316+
auto result = session.ExecuteDataQuery(upsertSql, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
5317+
UNIT_ASSERT(result.IsSuccess());
5318+
}
5319+
5320+
{
5321+
const TString createTableSql = R"(ALTER TABLE `/Root/table`
5322+
ADD INDEX value_index GLOBAL ON (value)
5323+
)";
5324+
5325+
auto result = session.ExecuteSchemeQuery(createTableSql).GetValueSync();
5326+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5327+
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS);
5328+
}
5329+
5330+
{
5331+
const auto& yson = ReadTablePartToYson(session, "/Root/table");
5332+
const TString expected = R"([[[0u];[1u]];[[10u];[11u]];[[100u];[101u]];[[200u];[201u]]])";
5333+
UNIT_ASSERT_VALUES_EQUAL(yson, expected);
5334+
}
5335+
5336+
{
5337+
const TString selectSql(Q1_(R"(
5338+
SELECT * FROM `/Root/table` VIEW value_index WHERE value > 100;
5339+
)"));
5340+
5341+
auto result = session.ExecuteDataQuery(selectSql, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
5342+
UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
5343+
UNIT_ASSERT(result.IsSuccess());
5344+
UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), R"([[[100u];[101u]];[[200u];[201u]]])");
5345+
}
5346+
}
52895347
}
52905348

52915349
}

ydb/core/tx/datashard/datashard_change_receiving.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,6 @@ class TDataShard::TTxApplyChangeRecords: public TTransactionBase<TDataShard> {
237237
for (size_t i = 0; i < tableInfo.KeyColumnTypes.size(); ++i) {
238238
const NScheme::TTypeId type = tableInfo.KeyColumnTypes.at(i).GetTypeId();
239239
const auto& cell = KeyCells.GetCells().at(i);
240-
241-
if (type == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127) {
242-
AddRecordStatus(ctx, record.GetOrder(), NKikimrChangeExchange::TEvStatus::STATUS_REJECT,
243-
NKikimrChangeExchange::TEvStatus::REASON_SCHEME_ERROR,
244-
"Keys with Uint8 column values >127 are currently prohibited");
245-
return false;
246-
}
247-
248240
keyBytes += cell.Size();
249241
Key.emplace_back(cell.AsRef(), type);
250242
}

ydb/core/tx/datashard/datashard_common_upload.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ bool TCommonUploadOps<TEvRequest, TEvResponse>::Execute(TDataShard* self, TTrans
131131
ui64 keyBytes = 0;
132132
for (const auto& kt : tableInfo.KeyColumnTypes) {
133133
const TCell& c = keyCells.GetCells()[ki];
134-
if (kt.GetTypeId() == NScheme::NTypeIds::Uint8 && !c.IsNull() && c.AsValue<ui8>() > 127) {
135-
SetError(NKikimrTxDataShard::TError::BAD_ARGUMENT, "Keys with Uint8 column values >127 are currently prohibited");
136-
return true;
137-
}
138-
139134
keyBytes += c.Size();
140135
key.emplace_back(TRawTypeValue(c.AsRef(), kt.GetTypeId()));
141136
++ki;

ydb/core/tx/datashard/datashard_direct_erase.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ TDirectTxErase::EStatus TDirectTxErase::CheckedExecute(
105105
for (size_t ki : xrange(tableInfo.KeyColumnTypes.size())) {
106106
const NScheme::TTypeId kt = tableInfo.KeyColumnTypes[ki].GetTypeId();
107107
const TCell& cell = keyCells.GetCells()[ki];
108-
109-
if (kt == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127) {
110-
status = NKikimrTxDataShard::TEvEraseRowsResponse::BAD_REQUEST;
111-
error = "Keys with Uint8 column values >127 are currently prohibited";
112-
return EStatus::Error;
113-
}
114-
115108
keyBytes += cell.Size();
116109
key.emplace_back(TRawTypeValue(cell.AsRef(), kt));
117110
}

ydb/core/tx/datashard/datashard_write_operation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ std::tuple<NKikimrTxDataShard::TError::EKind, TString> TValidatedWriteTxOperatio
144144
{
145145
ui64 keyBytes = 0;
146146
for (ui16 keyColIdx = 0; keyColIdx < tableInfo.KeyColumnIds.size(); ++keyColIdx) {
147-
const auto& cellType = tableInfo.KeyColumnTypes[keyColIdx];
148147
const TCell& cell = Matrix.GetCell(rowIdx, keyColIdx);
149-
if (cellType.GetTypeId() == NScheme::NTypeIds::Uint8 && !cell.IsNull() && cell.AsValue<ui8>() > 127)
150-
return {NKikimrTxDataShard::TError::BAD_ARGUMENT, TStringBuilder() << "Keys with Uint8 column values >127 are currently prohibited"};
151-
152148
keyBytes += cell.IsNull() ? 1 : cell.Size();
153149
}
154150

ydb/services/ydb/ydb_bulk_upsert_ut.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,7 @@ Y_UNIT_TEST_SUITE(YdbTableBulkUpsert) {
962962
for (ui32 i = 0; i < 256; ++i) {
963963
{
964964
auto res = TestUpsertRow(client, "/Root/ui8", i, 42);
965-
if (i <= 127)
966-
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::SUCCESS);
967-
else
968-
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::BAD_REQUEST);
965+
UNIT_ASSERT_VALUES_EQUAL(res.GetStatus(), EStatus::SUCCESS);
969966
}
970967

971968
{

0 commit comments

Comments
 (0)