Skip to content

Remove information schema references from sql module - #26057

Draft
pepijnve wants to merge 10 commits into
apache:mainfrom
pepijnve:information-schema-refactoring
Draft

pepijnve wants to merge 10 commits into
apache:mainfrom
pepijnve:information-schema-refactoring

Conversation

@pepijnve

@pepijnve pepijnve commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • None logged yet

This PR builds on #25887 so that should be merged first.

Rationale for this change

LogicalPlan has a representation for the DESCRIBE TABLE statement, but not for the various SHOW ... statements. This makes it necessary to lower SHOW statements to equivalent SELECT statements against the information_schema tables during SQL statement to logical plan conversion. The code in question is located in the sql module's SqlToRel::sql_statement_to_plan function.

As an example, show_tables_to_plan is implemented as

fn show_tables_to_plan(&self) -> Result<LogicalPlan> {
    if self.has_table("information_schema", "tables") {
        let query = "SELECT * FROM information_schema.tables;";
        let mut rewrite = DFParser::parse_sql(query)?;
        assert_eq!(rewrite.len(), 1);
        self.statement_to_plan(rewrite.pop_front().unwrap()) // length of rewrite is 1
    } else {
        plan_err!("SHOW TABLES is not supported unless information_schema is enabled")
    }
}

The implementation is simple enough, but has the downside that it hardcodes references to tables and their columns using magic strings in a module that should be independent of specific schemas, tables, and views. The exact set of columns (and hence the output format) of the show statements is being determined in the sql module which doesn't seem to be where it belongs. This is a logical-to-physical translation aspect, not a sql-to-logical one.

To move the translation to a more appropriate location, this MR extends the logical plan data model to support show statements as well. Rather than introducing a new plan type, the existing describe table plan type is extended to support all statements belonging to the family of introspection statements.

The logical-to-physical translation of show statements is move over to the physical_planner module next to the existing implementation for describe table.

What changes are included in this PR?

LogicalPlan::DescribeTable has been made been renamed to LogicalPlan::Show and extended to support all show statements.

Handling of show statements has been moved from sql::statement to core::physical_planner.

The implementations themselves have been decoupled from the information_schema tables. This allows SHOW statements to work even if the information schema provider is not enabled.

A new common::information_schema module has been added to avoid string based duplication of the information_schema schema. In other words, duplicate magic strings have been removed.

Are these changes tested?

Covered by SLTs

Are there any user-facing changes?

Yes

  • LogicalPlan::DescribeTable has been replaced with LogicalPlan::Show
  • Availability of SHOW statements is no longer tied to the information_schema schema being accessible in the catalog
  • information_schema.views no longer contains base tables

@github-actions github-actions Bot added documentation Improvements or additions to documentation sql SQL Planner logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate catalog Related to the catalog crate common Related to common crate execution Related to the execution crate proto Related to proto crate labels Oct 5, 2026
@pepijnve
pepijnve force-pushed the information-schema-refactoring branch from 3ec152b to 71f0578 Compare October 5, 2026 16:15
@pepijnve pepijnve changed the title Information schema refactoring Remove information schema references from SQL parser Oct 19, 2026
@pepijnve pepijnve changed the title Remove information schema references from SQL parser Remove information schema references from sql module Oct 19, 2026
@pepijnve pepijnve changed the title Remove information schema references from sql module Remove information schema references from sql module Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 logical-expr Logical plan and expressions optimizer Optimizer rules proto Related to proto crate sql SQL Planner sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants