Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not silently ignore temporary views
Browse files Browse the repository at this point in the history
alamb committed Sep 12, 2024

Verified

This commit was signed with the committer’s verified signature.
reneme René Meusel
1 parent 4ffb34d commit 6e09022
Showing 2 changed files with 54 additions and 10 deletions.
62 changes: 53 additions & 9 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,12 @@ use crate::utils::normalize_ident;

use arrow_schema::{DataType, Fields};
use datafusion_common::parsers::CompressionTypeVariant;
use datafusion_common::{exec_err, not_impl_err, plan_datafusion_err, plan_err, schema_err, unqualified_field_not_found, Column, Constraints, DFSchema, DFSchemaRef, DataFusionError, Result, ScalarValue, SchemaError, SchemaReference, TableReference, ToDFSchema};
use datafusion_common::{
exec_err, not_impl_err, plan_datafusion_err, plan_err, schema_err,
unqualified_field_not_found, Column, Constraints, DFSchema, DFSchemaRef,
DataFusionError, Result, ScalarValue, SchemaError, SchemaReference, TableReference,
ToDFSchema,
};
use datafusion_expr::dml::CopyTo;
use datafusion_expr::expr_rewriter::normalize_col_with_schemas_and_ambiguity_check;
use datafusion_expr::logical_plan::builder::project;
@@ -276,12 +281,22 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
return not_impl_err!("Volatile tables not supported")?;
}
if hive_distribution != ast::HiveDistributionStyle::NONE {
return not_impl_err!("Hive distribution not supported: {hive_distribution:?}")?;
return not_impl_err!(
"Hive distribution not supported: {hive_distribution:?}"
)?;
}
if !matches!(hive_formats, Some(ast::HiveFormat {
row_format:None,serde_properties:None,storage: None,location: None,
})) {
return not_impl_err!("Hive formats not supported: {hive_formats:?}")?;
if !matches!(
hive_formats,
Some(ast::HiveFormat {
row_format: None,
serde_properties: None,
storage: None,
location: None,
})
) {
return not_impl_err!(
"Hive formats not supported: {hive_formats:?}"
)?;
}
if file_format.is_some() {
return not_impl_err!("File format not supported")?;
@@ -350,7 +365,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
return not_impl_err!("Data retention time in days not supported")?;
}
if max_data_extension_time_in_days.is_some() {
return not_impl_err!("Max data extension time in days not supported")?;
return not_impl_err!(
"Max data extension time in days not supported"
)?;
}
if default_ddl_collation.is_some() {
return not_impl_err!("Default DDL collation not supported")?;
@@ -365,7 +382,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
return not_impl_err!("With tags not supported")?;
}


// Merge inline constraints and existing constraints
let mut all_constraints = constraints;
let inline_constraints = calc_inline_constraints_from_columns(&columns);
@@ -451,12 +467,40 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {

Statement::CreateView {
or_replace,
materialized,
name,
columns,
query,
options: CreateTableOptions::None,
..
cluster_by,
comment,
with_no_schema_binding,
if_not_exists,
temporary,
to,
} => {
if materialized {
return not_impl_err!("Materialized views not supported")?;
}
if !cluster_by.is_empty() {
return not_impl_err!("Cluster by not supported")?;
}
if comment.is_some() {
return not_impl_err!("Comment not supported")?;
}
if with_no_schema_binding {
return not_impl_err!("With no schema binding not supported")?;
}
if if_not_exists {
return not_impl_err!("If not exists not supported")?;
}
if temporary {
return not_impl_err!("Temporary views not supported")?;
}
if to.is_some() {
return not_impl_err!("To not supported")?;
}

let columns = columns
.into_iter()
.map(|view_column_def| {
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ CREATE TEMPORARY TABLE my_temp_table (
name TEXT NOT NULL
);

statement error DataFusion error: Error during planning: table 'datafusion\.public\.my_table' not found
statement error DataFusion error: This feature is not implemented: Temporary views not supported
CREATE TEMPORARY VIEW my_temp_view AS SELECT id, name FROM my_table;

# Partitioned table on a single file

0 comments on commit 6e09022

Please sign in to comment.