Skip to content

Commit f7eba99

Browse files
authored
Merge 7a7e90e into 903def9
2 parents 903def9 + 7a7e90e commit f7eba99

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

ydb/core/kqp/host/kqp_translate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ NSQLTranslation::TTranslationSettings GetTranslationSettings(NYql::EKikimrQueryT
9595
settings.DefaultCluster = cluster;
9696
settings.ClusterMapping = {
9797
{cluster, TString(NYql::KikimrProviderName)},
98-
{"pg_catalog", TString(NYql::PgProviderName)}
98+
{"pg_catalog", TString(NYql::PgProviderName)},
99+
{"information_schema", TString(NYql::PgProviderName)}
99100
};
100101
auto tablePathPrefix = kqpTablePathPrefix;
101102
if (!tablePathPrefix.empty()) {

ydb/core/kqp/ut/pg/pg_catalog_ut.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ Y_UNIT_TEST_SUITE(PgCatalog) {
3939
])", FormatResultSetYson(result.GetResultSet(0)));
4040
}
4141
}
42+
43+
Y_UNIT_TEST(InformationSchema) {
44+
TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false));
45+
auto db = kikimr.GetQueryClient();
46+
auto settings = NYdb::NQuery::TExecuteQuerySettings().Syntax(NYdb::NQuery::ESyntax::Pg);
47+
{
48+
auto result = db.ExecuteQuery(R"(
49+
select column_name from information_schema.columns
50+
order by table_schema, table_name, column_name limit 5
51+
)", NYdb::NQuery::TTxControl::BeginTx().CommitTx(), settings).ExtractValueSync();
52+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
53+
UNIT_ASSERT_C(!result.GetResultSets().empty(), "no result sets");
54+
CompareYson(R"([
55+
["authorization_identifier"];["fdwoptions"];["fdwowner"];["foreign_data_wrapper_catalog"];
56+
["foreign_data_wrapper_language"]
57+
])", FormatResultSetYson(result.GetResultSet(0)));
58+
}
59+
}
4260
}
4361

4462
} // namespace NKqp

ydb/library/yql/sql/pg/pg_sql.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,8 @@ class TConverter : public IPGParseEvents {
25592559
TAstNode* BuildTableKeyExpression(const TStringBuf relname,
25602560
const TStringBuf cluster, bool isScheme = false
25612561
) {
2562-
TString tableName = (cluster == "pg_catalog") ? TString(relname) : TablePathPrefix + relname;
2562+
bool noPrefix = (cluster == "pg_catalog" || cluster == "information_schema");
2563+
TString tableName = noPrefix ? TString(relname) : TablePathPrefix + relname;
25632564
return L(A("Key"), QL(QA(isScheme ? "tablescheme" : "table"),
25642565
L(A("String"), QAX(std::move(tableName)))));
25652566
}

0 commit comments

Comments
 (0)