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

Support CREATE/DROP/ALTER VIEW (and associated DataFrame functions) #1740

Closed
Igosuki opened this issue Feb 3, 2022 · 7 comments · Fixed by #2279
Closed

Support CREATE/DROP/ALTER VIEW (and associated DataFrame functions) #1740

Igosuki opened this issue Feb 3, 2022 · 7 comments · Fixed by #2279
Labels
enhancement New feature or request

Comments

@Igosuki
Copy link
Contributor

Igosuki commented Feb 3, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Currently we can create external and in memory listing tables, I want to go further and allow creating views from SQL queries.
Registering a dataframe as a table requires the following :

    let table = ctx.clone().sql(&sql_query).await?;
    let df_impl = Arc::new(DataFrameImpl::new(ctx.state.clone(), &table.to_logical_plan()));
    ctx.register_table(table_name.as_str(), df_impl.clone())?;

Describe the solution you'd like
Since DataframeImpl is already a TableType::View, registering/droping/altering a view could be done from SQL, or directly with ctx.create_view(df: Arc<dyn DataFrame>) or df.register_as_view(name: impl Into<TableReference>)
and

ctx.sql("CREATE VIEW records AS select * from other_records where ...")

Describe alternatives you've considered
Leaving things as is

Additional context
Make it easier to use arrow-datafusion without knowing its internals.

@Igosuki Igosuki added the enhancement New feature or request label Feb 3, 2022
@alamb
Copy link
Contributor

alamb commented Feb 3, 2022

🤔 since SchemaProvider already allows registering a new table provider, we might be able to implement this without any new traits

https://github.com/apache/arrow-datafusion/blob/6ec18bb4a53f684efd8d97443c55035eb37bda14/datafusion/src/catalog/schema.rs#L40-L51

@matthewmturner
Copy link
Contributor

Im very interested in this as well, in particular just getting started with enabling CREATE VIEW.

@Igosuki did you have plans to work on this?

@Igosuki
Copy link
Contributor Author

Igosuki commented Apr 4, 2022

I would love to but I am quite busy with other things these days (recently got knee surgery). So feel free to take ownership !

@matthewmturner
Copy link
Contributor

Sorry to hear - wishing you a speedy recovery!

I hope to look into it soon. Will keep you posted.

@alamb
Copy link
Contributor

alamb commented Apr 4, 2022

Create VIEW would be cool indeed -- I suggest adding it to the Catalog/Schema provider traits (as the view definitions logically belong there I think)

@matthewmturner
Copy link
Contributor

@alamb noted - i will look into that.

@matthewmturner
Copy link
Contributor

I have started work on CREATE VIEW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants