Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add catalog as part of the table path in plan_to_sql #10612

Merged
merged 2 commits into from
May 23, 2024
Merged

add catalog as part of the table path in plan_to_sql #10612

merged 2 commits into from
May 23, 2024

Conversation

y-f-u
Copy link
Contributor

@y-f-u y-f-u commented May 22, 2024

Which issue does this PR close?

TableReference has the catalog information but it's not used in plan_to_sql

Part of #9494

Rationale for this change

It's common for DBMS to have pattern of [catalog.][schema.]table_name in SQL statement. E.g. snowflake.

What changes are included in this PR?

  • Add catalog information if it exists in table reference.

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions bot added the sql SQL Planner label May 22, 2024
Copy link
Contributor

@phillipleblanc phillipleblanc left a comment

Choose a reason for hiding this comment

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

Thanks @y-f-u!

datafusion/sql/src/unparser/plan.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @y-f-u

And thank you for the review @phillipleblanc

It is somewhat hard to find the exsting tests for sql_to_plan. That might be nice to improve sometime

Field::new("id", DataType::Utf8, false),
Field::new("value", DataType::Utf8, false),
]);
let plan = table_scan(Some(table_name), &schema, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is testing plan_to_sql it might make more sense to put it with the rest of the tests for plan_to_sql: https://github.com/apache/datafusion/blob/main/datafusion/sql/tests/sql_integration.rs#L4669

However, the fact that those tests don't have "plan_to_sql" in their name is confusing too.

Maybe we could consolidate the tests into something like datafusion/sql/tests/sql_integration/plan_to_sql.rs 🤔 (as a follow on PR)

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #10635 to track

@alamb alamb merged commit 7757d63 into apache:main May 23, 2024
24 checks passed
@alamb
Copy link
Contributor

alamb commented May 23, 2024

Thanks again @y-f-u and @phillipleblanc

findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* add catalog as part of the table path in plan_to_sql

* Update datafusion/sql/src/unparser/plan.rs

Co-authored-by: Phillip LeBlanc <[email protected]>

---------

Co-authored-by: Phillip LeBlanc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants