diff --git a/datafusion/core/tests/sql/select.rs b/datafusion/core/tests/sql/select.rs index 5a56247e4f59..de608138fcc3 100644 --- a/datafusion/core/tests/sql/select.rs +++ b/datafusion/core/tests/sql/select.rs @@ -22,58 +22,9 @@ use datafusion::{ }; 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); @@ -84,37 +35,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.rs index 3d2fe492ca2e..e8c44babe98f 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 test async 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.slt new file mode 100644 index 000000000000..2d8209fb7b6d --- /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