Skip to content

Apache DataFusion SQL Query Engine

Minor: add err on `create` `temporary` table (#12439)

Haile47151fd2acd6
diff --git a/datafusion/sql/src/parser.rs b/datafusion/sql/src/parser.rs
index 2df8d89c59..744b56d552 100644
--- a/datafusion/sql/src/parser.rs
+++ b/datafusion/sql/src/parser.rs
@@ -544,6 +544,10 @@ impl<'a> DFParser<'a> {
} else if self.parser.parse_keyword(Keyword::UNBOUNDED) {
self.parser.expect_keyword(Keyword::EXTERNAL)?;
self.parse_create_external_table(true)
+ } else if self.parser.parse_keyword(Keyword::TEMPORARY) {
+ Err(ParserError::ParserError(
+ "Creating temporary tables is Unsupported".to_owned(),
+ ))
} else {
Ok(Statement::Statement(Box::from(self.parser.parse_create()?)))
}
diff --git a/datafusion/sqllogictest/test_files/create_external_table.slt b/datafusion/sqllogictest/test_files/create_external_table.slt
index e42d14e101..dcdb24c348 100644
--- a/datafusion/sqllogictest/test_files/create_external_table.slt
+++ b/datafusion/sqllogictest/test_files/create_external_table.slt
@@ -95,6 +95,16 @@ STORED AS CSV
LOCATION 'foo.csv'
OPTIONS ('format.delimiter' ';', 'format.column_index_truncate_length' '123')
+# Creating Temporary tables
+statement error DataFusion error: SQL error: ParserError\("Creating temporary tables is Unsupported"\)
+CREATE TEMPORARY TABLE my_temp_table (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL
+);
+
+statement error DataFusion error: SQL error: ParserError\("Creating temporary tables is Unsupported"\)
+CREATE TEMPORARY VIEW my_temp_view AS SELECT id, name FROM my_table;
+
# Partitioned table on a single file
query error DataFusion error: Error during planning: Can't create a partitioned table backed by a single file, perhaps the URL is missing a trailing slash\?
CREATE EXTERNAL TABLE single_file_partition(c1 int)