Skip to content

Commit

Permalink
KIKIMR-20539: resolve static information_schema tables (ydb-platform#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qrort authored Feb 7, 2024
1 parent 3079189 commit 76b6e78
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ydb/core/kqp/host/kqp_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ NSQLTranslation::TTranslationSettings GetTranslationSettings(NYql::EKikimrQueryT
settings.DefaultCluster = cluster;
settings.ClusterMapping = {
{cluster, TString(NYql::KikimrProviderName)},
{"pg_catalog", TString(NYql::PgProviderName)}
{"pg_catalog", TString(NYql::PgProviderName)},
{"information_schema", TString(NYql::PgProviderName)}
};
auto tablePathPrefix = kqpTablePathPrefix;
if (!tablePathPrefix.empty()) {
Expand Down
18 changes: 18 additions & 0 deletions ydb/core/kqp/ut/pg/pg_catalog_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ Y_UNIT_TEST_SUITE(PgCatalog) {
])", FormatResultSetYson(result.GetResultSet(0)));
}
}

Y_UNIT_TEST(InformationSchema) {
TKikimrRunner kikimr(NKqp::TKikimrSettings().SetWithSampleTables(false));
auto db = kikimr.GetQueryClient();
auto settings = NYdb::NQuery::TExecuteQuerySettings().Syntax(NYdb::NQuery::ESyntax::Pg);
{
auto result = db.ExecuteQuery(R"(
select column_name from information_schema.columns
order by table_schema, table_name, column_name limit 5
)", NYdb::NQuery::TTxControl::BeginTx().CommitTx(), settings).ExtractValueSync();
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
UNIT_ASSERT_C(!result.GetResultSets().empty(), "no result sets");
CompareYson(R"([
["authorization_identifier"];["fdwoptions"];["fdwowner"];["foreign_data_wrapper_catalog"];
["foreign_data_wrapper_language"]
])", FormatResultSetYson(result.GetResultSet(0)));
}
}
}

} // namespace NKqp
Expand Down
3 changes: 2 additions & 1 deletion ydb/library/yql/sql/pg/pg_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,8 @@ class TConverter : public IPGParseEvents {
TAstNode* BuildTableKeyExpression(const TStringBuf relname,
const TStringBuf cluster, bool isScheme = false
) {
TString tableName = (cluster == "pg_catalog") ? TString(relname) : TablePathPrefix + relname;
bool noPrefix = (cluster == "pg_catalog" || cluster == "information_schema");
TString tableName = noPrefix ? TString(relname) : TablePathPrefix + relname;
return L(A("Key"), QL(QA(isScheme ? "tablescheme" : "table"),
L(A("String"), QAX(std::move(tableName)))));
}
Expand Down

0 comments on commit 76b6e78

Please sign in to comment.