@@ -56,7 +56,7 @@ class TPgDataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
56
56
cluster = input->Child (TNode::idx_Cluster)->Content ();
57
57
}
58
58
59
- if (cluster != " pg_catalog" ) {
59
+ if (cluster != " pg_catalog" && cluster != " information_schema " ) {
60
60
ctx.AddError (TIssue (ctx.GetPosition (input->Pos ()), TStringBuilder () << " Unexpected cluster: " << cluster));
61
61
return TStatus::Error;
62
62
}
@@ -107,35 +107,45 @@ class TPgDataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
107
107
108
108
auto tableName = input->Child (TNode::idx_Table)->Content ();
109
109
TVector<const TItemExprType*> items;
110
- if (tableName == " pg_type" ) {
111
- FillPgTypeSchema (items, ctx);
112
- } else if (tableName == " pg_database" ) {
113
- FillPgDatabaseSchema (items, ctx);
114
- } else if (tableName == " pg_tablespace" ) {
115
- FillPgTablespaceSchema (items, ctx);
116
- } else if (tableName == " pg_shdescription" ) {
117
- FillPgShDescriptionSchema (items, ctx);
118
- } else if (tableName == " pg_trigger" ) {
119
- FillPgTriggerSchema (items, ctx);
120
- } else if (tableName == " pg_locks" ) {
121
- FillPgLocksSchema (items, ctx);
122
- } else if (tableName == " pg_stat_gssapi" ) {
123
- FillPgStatGssapiSchema (items, ctx);
124
- } else if (tableName == " pg_inherits" ) {
125
- FillPgInheritsSchema (items, ctx);
126
- } else if (tableName == " pg_stat_activity" ) {
127
- FillPgStatActivitySchema (items, ctx);
128
- } else if (tableName == " pg_timezone_names" ) {
129
- FillPgTimezoneNamesSchema (items, ctx);
130
- } else if (tableName == " pg_timezone_abbrevs" ) {
131
- FillPgTimezoneAbbrevsSchema (items, ctx);
132
- } else if (tableName == " pg_namespace" ) {
133
- FillPgNamespaceSchema (items, ctx);
134
- } else if (tableName == " pg_description" ) {
135
- FillPgDescriptionSchema (items, ctx);
136
- } else if (tableName == " pg_am" ) {
137
- FillPgAmSchema (items, ctx);
110
+ if (cluster == " pg_catalog" ) {
111
+ if (tableName == " pg_type" ) {
112
+ FillPgTypeSchema (items, ctx);
113
+ } else if (tableName == " pg_database" ) {
114
+ FillPgDatabaseSchema (items, ctx);
115
+ } else if (tableName == " pg_tablespace" ) {
116
+ FillPgTablespaceSchema (items, ctx);
117
+ } else if (tableName == " pg_shdescription" ) {
118
+ FillPgShDescriptionSchema (items, ctx);
119
+ } else if (tableName == " pg_trigger" ) {
120
+ FillPgTriggerSchema (items, ctx);
121
+ } else if (tableName == " pg_locks" ) {
122
+ FillPgLocksSchema (items, ctx);
123
+ } else if (tableName == " pg_stat_gssapi" ) {
124
+ FillPgStatGssapiSchema (items, ctx);
125
+ } else if (tableName == " pg_inherits" ) {
126
+ FillPgInheritsSchema (items, ctx);
127
+ } else if (tableName == " pg_stat_activity" ) {
128
+ FillPgStatActivitySchema (items, ctx);
129
+ } else if (tableName == " pg_timezone_names" ) {
130
+ FillPgTimezoneNamesSchema (items, ctx);
131
+ } else if (tableName == " pg_timezone_abbrevs" ) {
132
+ FillPgTimezoneAbbrevsSchema (items, ctx);
133
+ } else if (tableName == " pg_namespace" ) {
134
+ FillPgNamespaceSchema (items, ctx);
135
+ } else if (tableName == " pg_description" ) {
136
+ FillPgDescriptionSchema (items, ctx);
137
+ } else if (tableName == " pg_am" ) {
138
+ FillPgAmSchema (items, ctx);
139
+ } else if (tableName == " pg_tables" ) {
140
+ FillPgTablesSchema (items, ctx);
141
+ }
138
142
} else {
143
+ if (tableName == " tables" ) {
144
+ FillTablesSchema (items, ctx);
145
+ }
146
+ }
147
+
148
+ if (items.empty ()) {
139
149
ctx.AddError (TIssue (ctx.GetPosition (input->Child (TPgReadTable::idx_Table)->Pos ()), TStringBuilder () << " Unsupported table: " << tableName));
140
150
return TStatus::Error;
141
151
}
@@ -259,6 +269,16 @@ class TPgDataSourceTypeAnnotationTransformer : public TVisitorTransformerBase {
259
269
AddColumn (items, ctx, " amtype" , " char" );
260
270
}
261
271
272
+ void FillPgTablesSchema (TVector<const TItemExprType*>& items, TExprContext& ctx) {
273
+ AddColumn (items, ctx, " schemaname" , " name" );
274
+ AddColumn (items, ctx, " tablename" , " name" );
275
+ }
276
+
277
+ void FillTablesSchema (TVector<const TItemExprType*>& items, TExprContext& ctx) {
278
+ AddColumn (items, ctx, " table_schema" , " name" );
279
+ AddColumn (items, ctx, " table_name" , " name" );
280
+ }
281
+
262
282
void AddColumn (TVector<const TItemExprType*>& items, TExprContext& ctx, const TString& name, const TString& type) {
263
283
items.push_back (ctx.MakeType <TItemExprType>(name, ctx.MakeType <TPgExprType>(NPg::LookupType (type).TypeId )));
264
284
}
0 commit comments