Skip to content

Support partitioning of information schema content per catalog - #25887

Open
pepijnve wants to merge 20 commits into
apache:mainfrom
pepijnve:information-schema-extension
Open

pepijnve wants to merge 20 commits into
apache:mainfrom
pepijnve:information-schema-extension

Conversation

@pepijnve

@pepijnve pepijnve commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Catalog-qualified information schema queries currently return metadata for object from every registered catalog.

If we follow the letter of the SQL specification, my_catalog.information_schema.tables should describe only my_catalog. This is consistent with PostgreSQL's information schema representing the current database.

When working with multiple catalogs, for instance multiple Iceberg REST catalogs, it is more practical to be able to query just the objects defined in one specific catalog without further filtering.

A special 'system' catalog is optionally provided to be able to query across catalogs. This can be seen as an approximation of SQL's definition schema.

What changes are included in this PR?

  • The catalog list provided to InformationSchemaProvider is now constructed dynamically based on the catalog being queried. An optional 'system' catalog provides the existing global catalog behaviour. All other catalogs are restricted to just their own content.
  • Unqualified information_schema queries now use the configured default catalog instead of returning metadata from all catalogs.

What is the testing strategy for this PR?

Added multi-catalog SQL logic coverage for qualified and unqualified information schema queries.

Are there any user-facing changes?

Yes. Information schema results are now scoped to the resolved catalog.

@github-actions github-actions Bot added sql SQL Planner core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) catalog Related to the catalog crate common Related to common crate execution Related to the execution crate labels Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning c4f93bfb641f7d8a824a1510234d48a1e7ef1526
    Building datafusion v55.1.0 (current)
       Built [  61.908s] (current)
     Parsing datafusion v55.1.0 (current)
      Parsed [   0.035s] (current)
    Building datafusion v55.1.0 (baseline)
       Built [  17.673s] (baseline)
     Parsing datafusion v55.1.0 (baseline)
      Parsed [   0.035s] (baseline)
    Checking datafusion v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.665s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  82.044s] datafusion
    Building datafusion-catalog v55.1.0 (current)
       Built [  18.527s] (current)
     Parsing datafusion-catalog v55.1.0 (current)
      Parsed [   0.022s] (current)
    Building datafusion-catalog v55.1.0 (baseline)
       Built [  14.459s] (baseline)
     Parsing datafusion-catalog v55.1.0 (baseline)
      Parsed [   0.024s] (baseline)
    Checking datafusion-catalog v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.133s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  34.030s] datafusion-catalog
    Building datafusion-common v55.1.0 (current)
       Built [  19.262s] (current)
     Parsing datafusion-common v55.1.0 (current)
      Parsed [   0.077s] (current)
    Building datafusion-common v55.1.0 (baseline)
       Built [   1.179s] (baseline)
     Parsing datafusion-common v55.1.0 (baseline)
      Parsed [   0.078s] (baseline)
    Checking datafusion-common v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.710s] 229 checks: 228 pass, 1 fail, 0 warn, 31 skip

--- failure constructible_struct_adds_field: struct exhaustively constructible through public API adds field ---

Description:
A pub struct that could be exhaustively constructed with a literal using only public API has a new pub field, breaking existing exhaustive literals.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field CatalogOptions.system_catalog in /home/runner/work/datafusion/datafusion/datafusion/common/src/config.rs:225

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  22.212s] datafusion-common
    Building datafusion-execution v55.1.0 (current)
       Built [  10.073s] (current)
     Parsing datafusion-execution v55.1.0 (current)
      Parsed [   0.029s] (current)
    Building datafusion-execution v55.1.0 (baseline)
       Built [   5.703s] (baseline)
     Parsing datafusion-execution v55.1.0 (baseline)
      Parsed [   0.030s] (baseline)
    Checking datafusion-execution v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.311s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  17.038s] datafusion-execution
    Building datafusion-sql v55.1.0 (current)
       Built [  12.670s] (current)
     Parsing datafusion-sql v55.1.0 (current)
      Parsed [   0.034s] (current)
    Building datafusion-sql v55.1.0 (baseline)
       Built [  12.966s] (baseline)
     Parsing datafusion-sql v55.1.0 (baseline)
      Parsed [   0.036s] (baseline)
    Checking datafusion-sql v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.233s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  26.920s] datafusion-sql

@github-actions github-actions Bot added auto detected api change Auto detected API change documentation Improvements or additions to documentation labels Sep 29, 2026
@pepijnve
pepijnve force-pushed the information-schema-extension branch from b5c8c7a to 1b1ed04 Compare October 2, 2026 20:19
@pepijnve
pepijnve force-pushed the information-schema-extension branch from 1ae5b90 to 1e5b40e Compare October 3, 2026 13:24
@codecov-commenter

codecov-commenter commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.85047% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.93%. Comparing base (a9129e7) to head (de36547).
⚠️ Report is 62 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/catalog/src/information_schema.rs 78.07% 19 Missing and 6 partials ⚠️
datafusion/sql/src/statement.rs 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25887      +/-   ##
==========================================
+ Coverage   82.92%   82.93%   +0.01%     
==========================================
  Files        1155     1154       -1     
  Lines      458197   458155      -42     
  Branches   458197   458155      -42     
==========================================
+ Hits       379968   379985      +17     
+ Misses      55196    55140      -56     
+ Partials    23033    23030       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pepijnve
pepijnve marked this pull request as ready for review October 3, 2026 13:54
@pepijnve

pepijnve commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@neilconway this branch is now clean. There's still quite a lot that can be improved in the information schema, but I've restricted it to just the scope change here.

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pepijnve -- I am worried about the behavior change in this PR

I thought postgres had some notion of "default search path" or something that would scope its name resolution rules (and presumably also information_schema visibility). Did you consider something like that for DataFusion?

statement: Statement,
) -> datafusion_common::Result<LogicalPlan> {
let references = self.resolve_table_references(&statement)?;
let mut references = self.resolve_table_references(&statement)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice change to move it here into the session state

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that gives me the feeling I'm heading in the right direction.

Comment thread datafusion/sql/src/statement.rs
Comment thread datafusion/sql/src/statement.rs
@pepijnve

pepijnve commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

I think you're referring to PostgreSQL's schema search path. I'm not familiar with that, but will look into it.

@pepijnve

pepijnve commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

I spent some time surveying what's out there with AI to get a feel for our options.

We'll need to make a decision on a couple of things:

  1. Should information_schema be global or per catalog?
  2. If global, which catalog is it a child of?
  3. If per catalog, what does an unqualified usage of information_schema resolve to?

Here's what I got from Claude wrt other some other systems out there

System Global? Where it lives? Unqualified?
DuckDB Yes, one view covers all attached databases Once, in the system catalog system.information_schema
SQL Server No; query db.INFORMATION_SCHEMA.TABLES per database, or use sys.databases plus dynamic SQL Each database Current database (USE)
Snowflake No; SNOWFLAKE.ACCOUNT_USAGE views cover the account (with latency) Each database Current database; errors if none is set
Trino No; system.jdbc.* and system.metadata.* cover all catalogs Each catalog (generated per connector) Session catalog; errors if none is set
Databricks (Unity Catalog) Opt-in via system.information_schema Each catalog, plus system.information_schema Current catalog (USE CATALOG)
BigQuery Region-qualified, e.g. `region-us`.INFORMATION_SCHEMA.TABLES Per dataset or region, as a qualifier Generally errors without a qualifier
MySQL / MariaDB Yes, but "databases" are really schemas; table_catalog is always def Once, global The global schema
SQLite No; query aux.sqlite_schema per attachment None; each attached DB has sqlite_schema main.sqlite_schema
StarRocks No; query catalog.information_schema.tables per catalog (external catalogs supported from v3.2) Each catalog (default_catalog and each external catalog) Current catalog (SET CATALOG), default_catalog by default

The current state of DataFusion is somewhere in between all the choices listed above: information_schema lives in each catalog which suggests it's partitioned per catalog, but each 'instance' is identical and is actually global/cross-catalog. This becomes particularly annoying when you're trying to work with remote catalogs. It doesn't seem desirable for a query that looks local to start accessing remote resources (e.g., I try to query the memory catalog via the information schema, and it starts accessing my Iceberg REST catalog over the internet).

Given that a cross-catalog information schema currently exists, I think we at least need to retain that capability. The question then is how we expose that to the outside world.

What I did in this PR is to introduce a new magic catalog named system that holds the global information schema. Because DataFusion only has a single default catalog value at the moment rather than a PostgreSQL style search path, you need to address this explicitly.

An alternative solution could be to add a search path capability for unqualified identifier resolution. By default, we would not expose the per-catalog information schema and add system to the end of the search path by default. This would still introduce a behaviour change though for info schema queries in qualified form (i.e. select * from datafusion.information_schema.tables would not work).

A hybrid solution where we special case the unqualified resolution of information_schema is also an option.

@pepijnve

Copy link
Copy Markdown
Contributor Author

@alamb sorry to bother you, but if you have a moment could you let me know which direction seems the most promising to you? I'm happy to continue refining this PR, but not entirely sure what an acceptable end goal looks like.

@pepijnve pepijnve changed the title Information schema extension Partition information schema content per catalog Oct 16, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pepijnve

My core concern is that while the change proposed in this PR may likely be better / more standards compliant than what currently exists in DataFusion, it is likely to be treated as a major change by some downstream systems (for example InfluxDB would likely be impacted)

I think we need to add some way (e.g. an enum or InformationSchema view / registration API) to keep the existing behavior.

Another thing that might be more elegant maybe would be to update InformationSchemaProvider so that it doesn't require a catalog_list but instead just wraps a single Catalog.

We would still have to find some way to replicate the existing behavior of listing all the tables in all schemas

/// Retrieve the [`SchemaProvider`] for a specific [`TableReference`], if it
/// exists.
pub fn schema_for_ref(
&self,
table_ref: impl Into<TableReference>,
) -> datafusion_common::Result<Arc<dyn SchemaProvider>> {
let resolved_ref = self.resolve_table_ref(table_ref);
if self.config().information_schema()
&& *resolved_ref.schema == *INFORMATION_SCHEMA
{
return Ok(Arc::new(
InformationSchemaProvider::new(Arc::clone(&self.inner.catalog_list))
.with_table_functions(self.inner.table_functions.clone()),
));
}

🤔

Another idea would be to make some sort of InformationSchema builder or something similar that allowed finer grain control

@alamb

alamb commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

A hybrid solution where we special case the unqualified resolution of information_schema is also an option.

Perthaps you mean here some way to preserve the existing behavior

@pepijnve

Copy link
Copy Markdown
Contributor Author

A hybrid solution where we special case the unqualified resolution of information_schema is also an option.

Perthaps you mean here some way to preserve the existing behavior

Indeed. What I had in mind was that we would use the 'system catalog' configuration option for this. If it's undefined, then we stick to the current behaviour of every catalog containing being an identical, global one. If it is defined, then we make the per catalog instances so that they only describe objects in the same catalog and the global one provides the cross catalog variant. This way the change becomes opt-in.

@pepijnve

Copy link
Copy Markdown
Contributor Author

@alamb the most recent two commits change things so that the only remaining incompatible change is in the CLI where we'll need to decide what the default behaviour is. Should I revert that back to the current behaviour as well?

@alamb

alamb commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@alamb the most recent two commits change things so that the only remaining incompatible change is in the CLI where we'll need to decide what the default behaviour is. Should I revert that back to the current behaviour as well?

yes I think we should revert the CLI behavior back

I also tested again and found a few issues:

EXPLAIN SHOW TABLES stopped working:

On main:

andrewlamb@Andrews-MacBook-Pro-3 ~ % datafusion-cli
DataFusion CLI v55.1.0
> explain show tables;
+---------------+-------------------------------+
| plan_type     | plan                          |
+---------------+-------------------------------+
| physical_plan | ┌───────────────────────────┐ |
|               | │     StreamingTableExec    │ |
|               | │    --------------------   │ |
|               | │        limit: None        │ |
|               | └───────────────────────────┘ |
|               |                               |
+---------------+-------------------------------+
1 row(s) fetched.
Elapsed 0.004 seconds.

This PR:

> EXPLAIN SHOW TABLES;
Error during planning: SHOW TABLES is not supported unless information_schema is enabled
> show datafusion.catalog.information_schema;
+---------------------------------------+-------+
| name                                  | value |
+---------------------------------------+-------+
| datafusion.catalog.information_schema | true  |
+---------------------------------------+-------+
1 row(s) fetched.
Elapsed 0.012 seconds.

There are a bunch of new NULL views in information schema

> -- set up two catalogs with a table each
create catalog my_catalog;
create schema my_catalog.my_schema;
create table my_catalog.my_schema.t1 as values (1);
create view v1 as select 1;   -- a real view in datafusion.public, so a non-NULL definition shows up

-- scoped to the default catalog (datafusion)
select table_catalog, table_schema, table_name, definition from information_schema.views;

Main:

+---------------+--------------+------------+----------------------------+
| table_catalog | table_schema | table_name | definition                 |
+---------------+--------------+------------+----------------------------+
| my_catalog    | my_schema    | t1         | NULL                       |
| datafusion    | public       | v1         | CREATE VIEW v1 AS SELECT 1 |
+---------------+--------------+------------+----------------------------+

This PR

+---------------+--------------------+-------------+----------------------------+
| table_catalog | table_schema       | table_name  | definition                 |
+---------------+--------------------+-------------+----------------------------+
| datafusion    | public             | v1          | CREATE VIEW v1 AS SELECT 1 |
| datafusion    | information_schema | tables      | NULL                       |
| datafusion    | information_schema | views       | NULL                       |
| datafusion    | information_schema | columns     | NULL                       |
| datafusion    | information_schema | df_settings | NULL                       |
| datafusion    | information_schema | schemata    | NULL                       |
| datafusion    | information_schema | routines    | NULL                       |
| datafusion    | information_schema | parameters  | NULL                       |
+---------------+--------------------+-------------+----------------------------+
8 row(s) fetched.
Elapsed 0.005 seconds.

Change (in a good way)

Also, I think on main this sql query runs (weirdly as no_such_catalog does not exist)

however, on this PR it errors (which seems better)

-- Querying the information_schema of a catalog that does not exist
--   main:      returns the global listing (catalog name is ignored)
--   PR #25887: Error during planning: table 'no_such_catalog.information_schema.tables' not found
create catalog my_catalog;
create schema my_catalog.my_schema;
create table my_catalog.my_schema.t1 as values (1);

select table_catalog, table_schema, table_name
from no_such_catalog.information_schema.tables
where table_schema <> 'information_schema';

@pepijnve

Copy link
Copy Markdown
Contributor Author

yes I think we should revert the CLI behavior back

Will do

EXPLAIN SHOW TABLES stopped working

I'll look into that. I'll start by adding SLTs to cover the behaviour.

There are a bunch of new NULL views in information schema

Would you prefer to split that part off? The information_schema schema itself is included in the information_schema views since they do exist and can describe themselves. The view definition is a bit tricky to actually write though since these are implemented as virtual tables. We can fill in a pseudo definition if that's preferred over the null value, but it won't be SQL you can actually execute. We would have to describe what the underlying definition schema is then.

Example from postgresql

 table_catalog |    table_schema    |              table_name               |                                                                                                                                                                                                                                                                                                              view_definition
---------------+--------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 pepijn        | information_schema | schemata                              |  SELECT (current_database())::information_schema.sql_identifier AS catalog_name,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          +
               |                    |                                       |     (n.nspname)::information_schema.sql_identifier AS schema_name,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        +
               |                    |                                       |     (u.rolname)::information_schema.sql_identifier AS schema_owner,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       +
               |                    |                                       |     (NULL::name)::information_schema.sql_identifier AS default_character_set_catalog,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     +
               |                    |                                       |     (NULL::name)::information_schema.sql_identifier AS default_character_set_schema,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      +
               |                    |                                       |     (NULL::name)::information_schema.sql_identifier AS default_character_set_name,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        +
               |                    |                                       |     (NULL::character varying)::information_schema.character_data AS sql_path                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              +
               |                    |                                       |    FROM pg_namespace n,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   +
               |                    |                                       |     pg_authid u                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           +
               |                    |                                       |   WHERE ((n.nspowner = u.oid) AND (pg_has_role(n.nspowner, 'USAGE'::text) OR has_schema_privilege(n.oid, 'CREATE, USAGE'::text)));

@alamb

alamb commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Would you prefer to split that part off? The information_schema schema itself is included in the information_schema views since they do exist and can describe themselves.

If it is easy I recommend we do, if not it is ok to keep here

The view definition is a bit tricky to actually write though since these are implemented as virtual tables

Yeah I agree we shouldn't make up some SQL for a view that is dynamically created

@pepijnve

Copy link
Copy Markdown
Contributor Author

FYI, checking what 55.2.0 does reminded me of why I had fixed this. Resolves the inconsistency where querying tables lists a number of views, but querying views returns an empty set.

pepijn@Flandrien T % datafusion-cli
DataFusion CLI v55.2.0
> select * from information_schema.tables;
+---------------+--------------------+-------------+------------+
| table_catalog | table_schema       | table_name  | table_type |
+---------------+--------------------+-------------+------------+
| datafusion    | information_schema | tables      | VIEW       |
| datafusion    | information_schema | views       | VIEW       |
| datafusion    | information_schema | columns     | VIEW       |
| datafusion    | information_schema | df_settings | VIEW       |
| datafusion    | information_schema | schemata    | VIEW       |
| datafusion    | information_schema | routines    | VIEW       |
| datafusion    | information_schema | parameters  | VIEW       |
+---------------+--------------------+-------------+------------+
7 row(s) fetched.
Elapsed 0.002 seconds.

> select * from information_schema.views;
+---------------+--------------+------------+------------+
| table_catalog | table_schema | table_name | definition |
+---------------+--------------+------------+------------+
+---------------+--------------+------------+------------+
0 row(s) fetched.
Elapsed 0.003 seconds.

@pepijnve

pepijnve commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

I looked up the views table in the spec. Regarding the definition column I spotted this:

  1. Case:
    a) If the character representation of the user-specified <query expression> contained in the corresponding view descriptor can be represented without truncation, then the value of VIEW_DEFINITION is that character representation.
    b) Otherwise, the value of VIEW_DEFINITION is the null value.

Still compliant if we claim that the definition is so long that it would need to be truncated 😄

@pepijnve

Copy link
Copy Markdown
Contributor Author

Would you prefer to split that part off? The information_schema schema itself is included in the information_schema views since they do exist and can describe themselves.

If it is easy I recommend we do, if not it is ok to keep here

Just removing ~10 lines of code. All done.

@pepijnve pepijnve changed the title Partition information schema content per catalog Support partitioning of information schema content per catalog Oct 23, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pepijnve -- I think this looks good, and is a nice improvement and is ready to merge. Thank you for your patience

};

if require_info_schema {
if Self::requires_information_schema(&statement) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

use datafusion_common::TableReference;
use sqlparser::ast::*;

// following constants are used in `resolve_table_references`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is really nice to remove this stuff out of the sql module 💯 as it shouldn't really be in the sql parser

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're going to like my next PR 😄

@alamb
alamb added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2026
@pepijnve

Copy link
Copy Markdown
Contributor Author

I had missed the fact that there was a compile error when the sql feature is not enabled. Should be fixed now.

@alamb
alamb added this pull request to the merge queue Oct 24, 2026
@pepijnve

Copy link
Copy Markdown
Contributor Author

Is there a simple way to run the equivalent of cargo check datafusion features locally? I want to make sure I verify this proactively for the next PR.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2026
}

impl InformationSchemaProvider {
/// Creates a new [`InformationSchemaProvider`] for the provided `catalog_list`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Creates a new [`InformationSchemaProvider`] for the provided `catalog_list`
/// Creates a new [`InformationSchemaProvider`] for the provided `catalog`

sql_table_name: ObjectName,
) -> Result<LogicalPlan> {
if !self.has_table("information_schema", "tables") {
let Some(tables_table_ref) = self.resolve_info_table("views") else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
let Some(tables_table_ref) = self.resolve_info_table("views") else {
let Some(views_table_ref) = self.resolve_info_table("views") else {

to be clearer what it is about

Comment thread datafusion/core/src/execution/session_state.rs Outdated
| SQLStatement::ShowTables { .. }
| SQLStatement::ShowColumns { .. }
| SQLStatement::ShowVariable { .. }
| SQLStatement::ShowFunctions { .. }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShowStatus, ShowVariables and ShowCollation are no more matched. Intentional ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these don't actually have a backing implementation. Next PR will clean all this up properly.


if let Some(system_catalog_name) = &self.system_catalog_name {
for table_name in INFORMATION_SCHEMA_TABLES {
builder.add_table(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to https://github.com/apache/datafusion/pull/25887/changes#diff-8303a17e3c522b51c73c7fb0474b775746730873fc953e0c52c3fb7e67e84d5bR319 the system catalog could be a normal catalog this will add the same tables second time, no ?

data_type,
rid
FROM
information_schema.parameters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this use resolve_info_table("parameters") to resolve the correct catalog+schema+table ?

data_type,
rid
FROM
information_schema.parameters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

AND i.rid = o.rid
GROUP BY 1, 2, o.rid
) as p
JOIN information_schema.routines r

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_info_table("routines") ?!

);
};

let query = format!("SELECT * FROM {tables_table_ref};");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let query = format!("SELECT * FROM {tables_table_ref};");
let query = format!("SELECT * FROM {};", tables_table_ref.to_quoted_string());

quote that table name to support system catalog names like System

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if I handle this via the followup PR that removes the SQL composition altogether?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@pepijnve

Copy link
Copy Markdown
Contributor Author

Still some compilation issues when sql is disabled. I'll figure out how to test this locally, and tackle @martin-g's review comments while I'm at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change catalog Related to the catalog crate common Related to common crate core Core DataFusion crate documentation Improvements or additions to documentation execution Related to the execution crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

information_schema.tables contains all tables from all catalogs instead of current catalog

5 participants