Skip to content

Commit 6888c54

Browse files
authored
Rename Statement column to CreateQuery (#19357)
1 parent 95e96f8 commit 6888c54

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,7 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
27852785
UNIT_ASSERT(!result.GetResultSets().empty());
27862786

27872787
CompareYson(R"([
2788-
[["test_show_create"];["Table"];["CREATE TABLE `test_show_create` (\n `Key` Uint32,\n `Value` Uint32,\n PRIMARY KEY (`Key`)\n);\n"]];
2788+
[["CREATE TABLE `test_show_create` (\n `Key` Uint32,\n `Value` Uint32,\n PRIMARY KEY (`Key`)\n);\n"]; ["test_show_create"];["Table"];];
27892789
])", FormatResultSetYson(result.GetResultSet(0)));
27902790
}
27912791
}
@@ -2944,7 +2944,7 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
29442944
UNIT_ASSERT(!result.GetResultSets().empty());
29452945

29462946
CompareYson(R"([
2947-
[["test_view"];["View"];["CREATE VIEW `test_view` WITH (security_invoker = TRUE) AS\nSELECT\n *\nFROM\n KeyValue\n;\n"]];
2947+
[["CREATE VIEW `test_view` WITH (security_invoker = TRUE) AS\nSELECT\n *\nFROM\n KeyValue\n;\n"];["test_view"];["View"]];
29482948
])", FormatResultSetYson(result.GetResultSet(0)));
29492949
}
29502950
}

ydb/core/sys_view/common/schema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ struct Schema : NIceDb::Schema {
740740

741741
struct ShowCreate: Table<21> {
742742
struct Path: Column<1, NScheme::NTypeIds::Utf8> {};
743-
struct Statement: Column<2, NScheme::NTypeIds::Utf8> {};
743+
struct CreateQuery: Column<2, NScheme::NTypeIds::Utf8> {};
744744
struct PathType: Column<3, NScheme::NTypeIds::Utf8> {};
745745

746746
using TKey = TableKey<Path, PathType>;
747747
using TColumns = TableColumns<
748748
Path,
749-
Statement,
749+
CreateQuery,
750750
PathType
751751
>;
752752
};

ydb/core/sys_view/show_create/create_table_formatter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const TStr
457457
}
458458
}
459459

460-
TString statement = Stream.Str();
461-
TString formattedStatement;
460+
TString createQuery = Stream.Str();
461+
TString formattedCreateQuery;
462462
NYql::TIssues issues;
463-
if (!NYdb::NDump::Format(statement, formattedStatement, issues)) {
463+
if (!NYdb::NDump::Format(createQuery, formattedCreateQuery, issues)) {
464464
return TFormatResult(Ydb::StatusIds::INTERNAL_ERROR, issues.ToString());
465465
}
466466

467-
auto result = TFormatResult(std::move(formattedStatement));
467+
auto result = TFormatResult(std::move(formattedCreateQuery));
468468

469469
return result;
470470
}
@@ -1265,14 +1265,14 @@ TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const TStr
12651265
}
12661266
}
12671267

1268-
TString statement = Stream.Str();
1269-
TString formattedStatement;
1268+
TString createQuery = Stream.Str();
1269+
TString formattedCreateQuery;
12701270
NYql::TIssues issues;
1271-
if (!NYdb::NDump::Format(statement, formattedStatement, issues)) {
1271+
if (!NYdb::NDump::Format(createQuery, formattedCreateQuery, issues)) {
12721272
return TFormatResult(Ydb::StatusIds::INTERNAL_ERROR, issues.ToString());
12731273
}
12741274

1275-
auto result = TFormatResult(std::move(formattedStatement));
1275+
auto result = TFormatResult(std::move(formattedCreateQuery));
12761276

12771277
return result;
12781278
}

ydb/core/sys_view/show_create/show_create.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
217217
}
218218
}
219219

220-
void FillBatch(NKqp::TEvKqpCompute::TEvScanData& batch, const TString& path, const TString& statement) {
220+
void FillBatch(NKqp::TEvKqpCompute::TEvScanData& batch, const TString& path, const TString& createQuery) {
221221
TVector<TCell> cells;
222222
for (auto column : Columns) {
223223
switch (column.Tag) {
@@ -229,8 +229,8 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
229229
cells.emplace_back(TCell(PathType.data(), PathType.size()));
230230
break;
231231
}
232-
case Schema::ShowCreate::Statement::ColumnId: {
233-
cells.emplace_back(TCell(statement.data(), statement.size()));
232+
case Schema::ShowCreate::CreateQuery::ColumnId: {
233+
cells.emplace_back(TCell(createQuery.data(), createQuery.size()));
234234
break;
235235
}
236236
default:
@@ -249,7 +249,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
249249
const auto& record = ev->Get()->GetRecord();
250250
const auto status = record.GetStatus();
251251
std::optional<TString> path;
252-
std::optional<TString> statement;
252+
std::optional<TString> createQuery;
253253
switch (status) {
254254
case NKikimrScheme::StatusSuccess: {
255255
const auto& pathDescription = record.GetPathDescription();
@@ -292,7 +292,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
292292
auto formatterResult = formatter.Format(tablePath, Path, tableDesc, temporary, {}, {});
293293
if (formatterResult.IsSuccess()) {
294294
path = tablePath;
295-
statement = formatterResult.ExtractOut();
295+
createQuery = formatterResult.ExtractOut();
296296
} else {
297297
ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError());
298298
return;
@@ -316,7 +316,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
316316
auto formatterResult = formatter.Format(tablePath, Path, columnTableDesc, temporary);
317317
if (formatterResult.IsSuccess()) {
318318
path = tablePath;
319-
statement = formatterResult.ExtractOut();
319+
createQuery = formatterResult.ExtractOut();
320320
} else {
321321
ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError());
322322
return;
@@ -330,7 +330,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
330330
TCreateViewFormatter formatter;
331331
auto formatterResult = formatter.Format(*path, Path, description);
332332
if (formatterResult.IsSuccess()) {
333-
statement = formatterResult.ExtractOut();
333+
createQuery = formatterResult.ExtractOut();
334334
} else {
335335
return ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError());
336336
}
@@ -364,11 +364,11 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
364364
}
365365

366366
Y_ENSURE(path.has_value());
367-
Y_ENSURE(statement.has_value());
367+
Y_ENSURE(createQuery.has_value());
368368

369369
auto batch = MakeHolder<NKqp::TEvKqpCompute::TEvScanData>(ScanId);
370370

371-
FillBatch(*batch, path.value(), statement.value());
371+
FillBatch(*batch, path.value(), createQuery.value());
372372

373373
SendBatch(std::move(batch));
374374
}
@@ -378,7 +378,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
378378
const auto& record = ev->Get()->GetRecord();
379379
const auto status = record.GetStatus();
380380
std::optional<TString> path;
381-
std::optional<TString> statement;
381+
std::optional<TString> createQuery;
382382
switch (status) {
383383
case NKikimrScheme::StatusSuccess: {
384384
auto currentPath = record.GetPath();
@@ -419,7 +419,7 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
419419
);
420420
if (formatterResult.IsSuccess()) {
421421
path = CollectTableSettingsState->TablePath;
422-
statement = formatterResult.ExtractOut();
422+
createQuery = formatterResult.ExtractOut();
423423
} else {
424424
ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError());
425425
return;
@@ -453,11 +453,11 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
453453
}
454454

455455
Y_ENSURE(path.has_value());
456-
Y_ENSURE(statement.has_value());
456+
Y_ENSURE(createQuery.has_value());
457457

458458
auto batch = MakeHolder<NKqp::TEvKqpCompute::TEvScanData>(ScanId);
459459

460-
FillBatch(*batch, path.value(), statement.value());
460+
FillBatch(*batch, path.value(), createQuery.value());
461461

462462
SendBatch(std::move(batch));
463463
}
@@ -494,21 +494,21 @@ class TShowCreate : public TScanActorBase<TShowCreate> {
494494
CollectTableSettingsState->Sequences
495495
);
496496
std::optional<TString> path;
497-
std::optional<TString> statement;
497+
std::optional<TString> createQuery;
498498
if (formatterResult.IsSuccess()) {
499499
path = CollectTableSettingsState->TablePath;
500-
statement = formatterResult.ExtractOut();
500+
createQuery = formatterResult.ExtractOut();
501501
} else {
502502
ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError());
503503
return;
504504
}
505505

506506
Y_ENSURE(path.has_value());
507-
Y_ENSURE(statement.has_value());
507+
Y_ENSURE(createQuery.has_value());
508508

509509
auto batch = MakeHolder<NKqp::TEvKqpCompute::TEvScanData>(ScanId);
510510

511-
FillBatch(*batch, path.value(), statement.value());
511+
FillBatch(*batch, path.value(), createQuery.value());
512512

513513
SendBatch(std::move(batch));
514514
}

ydb/core/sys_view/ut_kqp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class TShowCreateChecker {
425425
TResultSetParser parser(resultSet);
426426
UNIT_ASSERT(parser.TryNextRow());
427427

428-
TString statement = "";
428+
TString createQuery = "";
429429

430430
for (const auto& column : columnsMeta) {
431431
TValueParser parserValue(parser.GetValue(column.Name));
@@ -437,15 +437,15 @@ class TShowCreateChecker {
437437
} else if (column.Name == "PathType") {
438438
auto actualType = to_upper(TString(value));
439439
UNIT_ASSERT_VALUES_EQUAL(actualType, type);
440-
} else if (column.Name == "Statement") {
441-
statement = value;
440+
} else if (column.Name == "CreateQuery") {
441+
createQuery = value;
442442
} else {
443443
UNIT_FAIL("Invalid column name: " << column.Name);
444444
}
445445
}
446-
UNIT_ASSERT(statement);
446+
UNIT_ASSERT(createQuery);
447447

448-
return statement;
448+
return createQuery;
449449
}
450450

451451
std::string ShowCreateTable(NQuery::TSession& session, const std::string& tableName) {

ydb/tests/stress/show_create/view/workload/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,29 @@ def _showing_loop(self):
171171
logger.error(f"[{thread_name}] SHOW CREATE VIEW `{self.view_path}` returned no data.")
172172
show_had_critical_error = True
173173
else:
174-
statement_column_index = -1
174+
create_query_column_index = -1
175175
for i, col in enumerate(result_sets[0].columns):
176-
if col.name == "Statement":
177-
statement_column_index = i
176+
if col.name == "CreateQuery":
177+
create_query_column_index = i
178178
break
179-
if statement_column_index == -1:
179+
if create_query_column_index == -1:
180180
logger.error(
181-
f"[{thread_name}] Column 'Statement' not found in SHOW CREATE VIEW result for {self.view_path}."
181+
f"[{thread_name}] Column 'CreateQuery' not found in SHOW CREATE VIEW result for {self.view_path}."
182182
)
183183
show_had_critical_error = True
184184
else:
185-
create_statement = result_sets[0].rows[0][statement_column_index]
186-
logger.debug(f"[{thread_name}] SHOW CREATE VIEW `{self.view_path}` result:\n{create_statement}")
185+
create_query = result_sets[0].rows[0][create_query_column_index]
186+
logger.debug(f"[{thread_name}] SHOW CREATE VIEW `{self.view_path}` result:\n{create_query}")
187187

188188
expected_view_substr = f"CREATE VIEW `{self.view_path}`"
189189
expected_table_substr = f"FROM\n `{self.table_path}`"
190190

191-
if not (expected_view_substr in create_statement and expected_table_substr in create_statement):
191+
if not (expected_view_substr in create_query and expected_table_substr in create_query):
192192
logger.error(
193193
f"[{thread_name}] VALIDATION FAILED for `{self.view_path}`:\n"
194194
f" Expected view part: '{expected_view_substr}'\n"
195195
f" Expected table part: '{expected_table_substr}'\n"
196-
f" Got:\n{create_statement}"
196+
f" Got:\n{create_query}"
197197
)
198198
show_had_critical_error = True
199199
else:

0 commit comments

Comments
 (0)