@@ -887,23 +887,23 @@ TExprNode::TPtr KiBuildQuery(TExprBase node, TExprContext& ctx, TStringBuf datab
887
887
888
888
TNodeOnNodeOwnedMap replaces;
889
889
std::unordered_set<std::string> pgDynTables = {" pg_tables" , " tables" , " pg_class" };
890
- std::unordered_map<const NYql::TExprNode*, TString> tableNames;
891
- VisitExpr (node.Ptr (), [&replaces, &tableNames, &pgDynTables](const TExprNode::TPtr& input) -> bool {
890
+ VisitExpr (node.Ptr (), [&replaces, &pgDynTables](const TExprNode::TPtr& input) -> bool {
892
891
if (input->IsCallable (" PgTableContent" )) {
893
892
TPgTableContent content (input);
894
893
if (pgDynTables.contains (content.Table ().StringValue ())) {
895
894
replaces[input.Get ()] = nullptr ;
896
- tableNames[input.Get ()] = content.Table ().StringValue ();
897
895
}
898
896
}
899
897
return true ;
900
898
});
901
899
if (!replaces.empty ()) {
902
- for (auto & [key, _] : replaces) {
900
+ for (auto & [input, _] : replaces) {
901
+ TPgTableContent content (input);
902
+
903
903
TExprNode::TPtr path = ctx.NewCallable (
904
904
node.Pos (),
905
905
" String" ,
906
- { ctx.NewAtom (node.Pos (), TStringBuilder () << " /" << database << " /.sys/" << tableNames[key] ) }
906
+ { ctx.NewAtom (node.Pos (), TStringBuilder () << " /" << database << " /.sys/" << content. Table (). StringValue () ) }
907
907
);
908
908
auto table = ctx.NewList (node.Pos (), {ctx.NewAtom (node.Pos (), " table" ), path});
909
909
auto newKey = ctx.NewCallable (node.Pos (), " Key" , {table});
@@ -923,10 +923,21 @@ TExprNode::TPtr KiBuildQuery(TExprBase node, TExprContext& ctx, TStringBuf datab
923
923
.Build ()
924
924
.Done ().Ptr ();
925
925
926
+
926
927
auto readData = Build<TCoRight>(ctx, node.Pos ())
927
928
.Input (ydbSysTableRead)
928
929
.Done ().Ptr ();
929
- replaces[key] = readData;
930
+
931
+ if (auto v = content.Columns ().Maybe <TCoVoid>()) {
932
+ replaces[input] = readData;
933
+ } else {
934
+ auto extractMembers = Build<TCoExtractMembers>(ctx, node.Pos ())
935
+ .Input (readData)
936
+ .Members (content.Columns ().Ptr ())
937
+ .Done ().Ptr ();
938
+
939
+ replaces[input] = extractMembers;
940
+ }
930
941
}
931
942
ctx.Step
932
943
.Repeat (TExprStep::ExprEval)
0 commit comments