Skip to content

Commit ab119a2

Browse files
authored
Fix pg_tables when not using /Root database (#6032)
1 parent 40800f5 commit ab119a2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

ydb/core/kqp/provider/yql_kikimr_opt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TAutoPtr<IGraphTransformer> CreateKiLogicalOptProposalTransformer(TIntrusivePtr<
6060
if (auto maybeDatasink = node.Maybe<TCoCommit>().DataSink().Maybe<TKiDataSink>()) {
6161
auto cluster = TString(maybeDatasink.Cast().Cluster());
6262

63-
ret = KiBuildQuery(node, ctx, sessionCtx->TablesPtr(), types, sessionCtx->Query().ConcurrentResults);
63+
ret = KiBuildQuery(node, ctx, sessionCtx->GetDatabase(), sessionCtx->TablesPtr(), types, sessionCtx->Query().ConcurrentResults);
6464

6565
if (ret != inputNode) {
6666
return ret;

ydb/core/kqp/provider/yql_kikimr_opt_build.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ TVector<TKiDataQueryBlock> MakeKiDataQueryBlocks(TExprBase node, const TKiExplor
844844

845845
} // namespace
846846

847-
TExprNode::TPtr KiBuildQuery(TExprBase node, TExprContext& ctx, TIntrusivePtr<TKikimrTablesData> tablesData,
847+
TExprNode::TPtr KiBuildQuery(TExprBase node, TExprContext& ctx, TStringBuf database, TIntrusivePtr<TKikimrTablesData> tablesData,
848848
TTypeAnnotationContext& types, bool concurrentResults) {
849849
if (!node.Maybe<TCoCommit>().DataSink().Maybe<TKiDataSink>()) {
850850
return node.Ptr();
@@ -858,14 +858,14 @@ TExprNode::TPtr KiBuildQuery(TExprBase node, TExprContext& ctx, TIntrusivePtr<TK
858858
VisitExpr(node.Ptr(), [&replaces](const TExprNode::TPtr& input) -> bool {
859859
if (input->IsCallable("PgTableContent")) {
860860
TPgTableContent content(input);
861-
if (content.Table() == "pg_tables") {
861+
if (content.Table().StringValue() == "pg_tables") {
862862
replaces[input.Get()] = nullptr;
863863
}
864864
}
865865
return true;
866866
});
867867
if (!replaces.empty()) {
868-
TExprNode::TPtr path = ctx.NewCallable(node.Pos(), "String", { ctx.NewAtom(node.Pos(), "/Root/.sys/pg_tables") });
868+
TExprNode::TPtr path = ctx.NewCallable(node.Pos(), "String", { ctx.NewAtom(node.Pos(), TStringBuilder() << "/" << database << "/.sys/pg_tables") });
869869
auto table = ctx.NewList(node.Pos(), {ctx.NewAtom(node.Pos(), "table"), path});
870870
auto newKey = ctx.NewCallable(node.Pos(), "Key", {table});
871871

ydb/core/kqp/provider/yql_kikimr_provider_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void FillLiteralProto(const NNodes::TCoDataCtor& literal, Ydb::TypedValue& proto
249249
void FillLiteralProto(const NNodes::TCoDataCtor& literal, NKqpProto::TKqpPhyLiteralValue& proto);
250250

251251
// Optimizer rules
252-
TExprNode::TPtr KiBuildQuery(NNodes::TExprBase node, TExprContext& ctx, TIntrusivePtr<TKikimrTablesData> tablesData,
252+
TExprNode::TPtr KiBuildQuery(NNodes::TExprBase node, TExprContext& ctx, TStringBuf database, TIntrusivePtr<TKikimrTablesData> tablesData,
253253
TTypeAnnotationContext& types, bool sequentialResults);
254254
TExprNode::TPtr KiBuildResult(NNodes::TExprBase node, const TString& cluster, TExprContext& ctx);
255255

0 commit comments

Comments
 (0)