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

Allow table providers to indicate their type for catalog metadata #205

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

returnString
Copy link
Contributor

@returnString returnString commented Apr 26, 2021

Which issue does this PR close?

Closes #191.

Rationale for this change

This allows registered TableProviders to approximately indicate the mechanism used to retrieve data during query execution, which in turn allows tables to be logged with a table_type column in information_schema.tables. This was previously partially supported by classifying all registered tables as BASE TABLE and all generated system tables as VIEW.

This means that DataFusion consumers can now build systems that allow end-users to differentiate between relation types. For example, you could build a TableProvider that stores a query plan, use this as a view in your execution context, and end users would be aware that any queries over it in turn trigger a query internally. This is also often used to split relations into different lists for tables vs views in GUI/IDE setups.

What changes are included in this PR?

  • Added TableType enum
  • Exposed new trait method, TableProvider::table_type
  • Updated information_schema builder to use new table types

Are there any user-facing changes?

TableProvider::table_type is introduced as a new trait method, but comes with a default implementation returning TableType::Base to preserve back-compat.

@codecov-commenter
Copy link

Codecov Report

Merging #205 (08e0044) into master (ddaea81) will decrease coverage by 0.01%.
The diff coverage is 72.22%.

❗ Current head 08e0044 differs from pull request most recent head 589d8fa. Consider uploading reports for the commit 589d8fa to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #205      +/-   ##
==========================================
- Coverage   76.35%   76.33%   -0.02%     
==========================================
  Files         134      134              
  Lines       23018    23042      +24     
==========================================
+ Hits        17576    17590      +14     
- Misses       5442     5452      +10     
Impacted Files Coverage Δ
datafusion/src/execution/context.rs 92.63% <68.75%> (-0.31%) ⬇️
datafusion/src/catalog/information_schema.rs 86.72% <72.22%> (-2.06%) ⬇️
datafusion/src/datasource/datasource.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddaea81...589d8fa. Read the comment docs.

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.

looks great to me. Thanks @returnString

I plan to leave this open for a bit to see if anyone else has comments, but I think it is ready to go

/// An ordinary physical table.
Base,
/// A non-materialised table that itself uses a query internally to provide data.
View,
Copy link
Contributor

Choose a reason for hiding this comment

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

A preview of things to come, perhaps :)

@alamb alamb merged commit 14f1eeb into apache:master Apr 28, 2021
@returnString returnString deleted the table_types branch April 28, 2021 10:31
@houqp houqp added ballista datafusion Changes in the datafusion crate enhancement New feature or request labels Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow TableProviders to indicate their type for the information schema
5 participants