Skip to content

Commit 13c6e2a

Browse files
authored
Apply TablePathPrefix to topic. (#4866)
1 parent 5296d28 commit 13c6e2a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

ydb/library/yql/sql/v1/query.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ class TTopicKey: public ITableKeys {
120120
return Name.GetLiteral() ? &Full : nullptr;
121121
}
122122

123-
TNodePtr BuildKeys(TContext&, ITableKeys::EBuildKeysMode) override {
124-
auto path = Name.Build(); // ToDo Need some prefix here?
123+
TNodePtr BuildKeys(TContext& ctx, ITableKeys::EBuildKeysMode) override {
124+
const auto path = ctx.GetPrefixedPath(Service, Cluster, Name);
125125
if (!path) {
126126
return nullptr;
127127
}

ydb/library/yql/sql/v1/sql_ut.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -6279,6 +6279,20 @@ Y_UNIT_TEST_SUITE(TopicsDDL) {
62796279
ALTER CONSUMER consumer3 SET (read_from = 2);
62806280
)", false);
62816281
}
6282+
6283+
Y_UNIT_TEST(TopicWithPrefix) {
6284+
NYql::TAstParseResult res = SqlToYql(R"(
6285+
USE plato;
6286+
PRAGMA TablePathPrefix = '/database/path/to/tables';
6287+
ALTER TOPIC `my_table/my_feed` ADD CONSUMER `my_consumer`;
6288+
)");
6289+
UNIT_ASSERT(res.Root);
6290+
6291+
TWordCountHive elementStat = {{TString("/database/path/to/tables/my_table/my_feed"), 0}, {"topic", 0}};
6292+
VerifyProgram(res, elementStat);
6293+
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["topic"]);
6294+
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["/database/path/to/tables/my_table/my_feed"]);
6295+
}
62826296
}
62836297

62846298
Y_UNIT_TEST_SUITE(BlockEnginePragma) {

0 commit comments

Comments
 (0)