Apache DataFusion SQL Query Engine
Move subset of select tests to sqllogic (#4583)
Ajaya Agrawal4d3065e5262d
diff --git a/datafusion/core/tests/sql/select.rs b/datafusion/core/tests/sql/select.rsindex c82eee7d0f..35d8dc6d6e 100644--- a/datafusion/core/tests/sql/select.rs+++ b/datafusion/core/tests/sql/select.rs@@ -23,58 +23,9 @@ use datafusion::{use datafusion_common::ScalarValue;use tempfile::TempDir;-#[tokio::test]-async fn all_where_empty() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;- let sql = "SELECT *- FROM aggregate_test_100- WHERE 1=2";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec!["++", "++"];- assert_batches_eq!(expected, &actual);- Ok(())-}-#[tokio::test]async fn select_values_list() -> Result<()> {let ctx = SessionContext::new();- {- let sql = "VALUES (1)";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+---------+",- "| column1 |",- "+---------+",- "| 1 |",- "+---------+",- ];- assert_batches_eq!(expected, &actual);- }- {- let sql = "VALUES (-1)";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+---------+",- "| column1 |",- "+---------+",- "| -1 |",- "+---------+",- ];- assert_batches_eq!(expected, &actual);- }- {- let sql = "VALUES (2+1,2-1,2>1)";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+---------+---------+---------+",- "| column1 | column2 | column3 |",- "+---------+---------+---------+",- "| 3 | 1 | true |",- "+---------+---------+---------+",- ];- assert_batches_eq!(expected, &actual);- }{let sql = "VALUES";let plan = ctx.create_logical_plan(sql);@@ -85,37 +36,11 @@ async fn select_values_list() -> Result<()> {let plan = ctx.create_logical_plan(sql);assert!(plan.is_err());}- {- let sql = "VALUES (1),(2)";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+---------+",- "| column1 |",- "+---------+",- "| 1 |",- "| 2 |",- "+---------+",- ];- assert_batches_eq!(expected, &actual);- }{let sql = "VALUES (1),()";let plan = ctx.create_logical_plan(sql);assert!(plan.is_err());}- {- let sql = "VALUES (1,'a'),(2,'b')";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+---------+---------+",- "| column1 | column2 |",- "+---------+---------+",- "| 1 | a |",- "| 2 | b |",- "+---------+---------+",- ];- assert_batches_eq!(expected, &actual);- }{let sql = "VALUES (1),(1,2)";let plan = ctx.create_logical_plan(sql);diff --git a/datafusion/core/tests/sqllogictests/src/main.rs b/datafusion/core/tests/sqllogictests/src/main.rsindex 3d2fe492ca..e8c44babe9 100644--- a/datafusion/core/tests/sqllogictests/src/main.rs+++ b/datafusion/core/tests/sqllogictests/src/main.rs@@ -153,7 +153,7 @@ fn check_test_file(filters: &[&str], path: &Path) -> bool {/// Create a SessionContext, configured for the specific testasync fn context_for_test_file(file_name: &str) -> SessionContext {match file_name {- "aggregate.slt" => {+ "aggregate.slt" | "select.slt" => {info!("Registering aggregate tables");let ctx = SessionContext::new();setup::register_aggregate_tables(&ctx).await;diff --git a/datafusion/core/tests/sqllogictests/test_files/select.slt b/datafusion/core/tests/sqllogictests/test_files/select.sltnew file mode 100644index 0000000000..2d8209fb7b--- /dev/null+++ b/datafusion/core/tests/sqllogictests/test_files/select.slt@@ -0,0 +1,58 @@++# Licensed to the Apache Software Foundation (ASF) under one+# or more contributor license agreements. See the NOTICE file+# distributed with this work for additional information+# regarding copyright ownership. The ASF licenses this file+# to you under the Apache License, Version 2.0 (the+# "License"); you may not use this file except in compliance+# with the License. You may obtain a copy of the License at++# http://www.apache.org/licenses/LICENSE-2.0++# Unless required by applicable law or agreed to in writing,+# software distributed under the License is distributed on an+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+# KIND, either express or implied. See the License for the+# specific language governing permissions and limitations+# under the License.++##########+## SELECT Tests+##########++# all where empty+query II+SELECT * FROM aggregate_test_100 WHERE 1=2+----++# Simple values function+query I+VALUES (1)+----+1++# VALUES with a negative values+query I+VALUES (-1)+----+-1++# foo bar+query IIC+VALUES (2+1,2-1,2>1)+----+3 1 true++# multiple rows values+query I+VALUES (1),(2)+----+1+2++# multiple rows and columns from VALUES+query IC+VALUES (1,'a'),(2,'b')+----+1 a+2 b\ No newline at end of file