Skip to content

Commit

Permalink
Apply TablePathPrefix to topic. (ydb-platform#4741)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony-Romanov authored May 22, 2024
1 parent a26dfc6 commit 3a59d95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ydb/library/yql/sql/v1/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class TTopicKey: public ITableKeys {
return Name.GetLiteral() ? &Full : nullptr;
}

TNodePtr BuildKeys(TContext&, ITableKeys::EBuildKeysMode) override {
auto path = Name.Build(); // ToDo Need some prefix here?
TNodePtr BuildKeys(TContext& ctx, ITableKeys::EBuildKeysMode) override {
const auto path = ctx.GetPrefixedPath(Service, Cluster, Name);
if (!path) {
return nullptr;
}
Expand Down
14 changes: 14 additions & 0 deletions ydb/library/yql/sql/v1/sql_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6515,6 +6515,20 @@ Y_UNIT_TEST_SUITE(TopicsDDL) {
ALTER CONSUMER consumer3 SET (read_from = 2);
)", false);
}

Y_UNIT_TEST(TopicWithPrefix) {
NYql::TAstParseResult res = SqlToYql(R"(
USE plato;
PRAGMA TablePathPrefix = '/database/path/to/tables';
ALTER TOPIC `my_table/my_feed` ADD CONSUMER `my_consumer`;
)");
UNIT_ASSERT(res.Root);

TWordCountHive elementStat = {{TString("/database/path/to/tables/my_table/my_feed"), 0}, {"topic", 0}};
VerifyProgram(res, elementStat);
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["topic"]);
UNIT_ASSERT_VALUES_EQUAL(1, elementStat["/database/path/to/tables/my_table/my_feed"]);
}
}

Y_UNIT_TEST_SUITE(BlockEnginePragma) {
Expand Down

0 comments on commit 3a59d95

Please sign in to comment.