Apache DataFusion SQL Query Engine
Port tests in wildcard.rs to sqllogictest (#6249)
masanobbb39ad9e82e1c0
diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rsindex 6729e6215b..cbccf333b3 100644--- a/datafusion/core/tests/sql/mod.rs+++ b/datafusion/core/tests/sql/mod.rs@@ -98,7 +98,6 @@ pub mod references;pub mod select;pub mod timestamp;pub mod udf;-pub mod wildcard;pub mod window;pub mod explain;diff --git a/datafusion/core/tests/sql/wildcard.rs b/datafusion/core/tests/sql/wildcard.rsdeleted file mode 100644index 8cecfd829e..0000000000--- a/datafusion/core/tests/sql/wildcard.rs+++ /dev/null@@ -1,143 +0,0 @@-// 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.--use super::*;--#[tokio::test]-async fn select_qualified_wildcard() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_simple_csv(&ctx).await?;-- let sql = "SELECT agg.* FROM aggregate_simple as agg order by c1";- let results = execute_to_batches(&ctx, sql).await;-- let expected = vec![- "+---------+---------+-------+",- "| c1 | c2 | c3 |",- "+---------+---------+-------+",- "| 0.00001 | 1.0e-12 | true |",- "| 0.00002 | 2.0e-12 | false |",- "| 0.00002 | 2.0e-12 | false |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "+---------+---------+-------+",- ];-- assert_batches_eq!(expected, &results);-- Ok(())-}--#[tokio::test]-async fn select_non_alias_qualified_wildcard() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_simple_csv(&ctx).await?;-- let sql = "SELECT aggregate_simple.* FROM aggregate_simple order by c1";- let results = execute_to_batches(&ctx, sql).await;-- let expected = vec![- "+---------+---------+-------+",- "| c1 | c2 | c3 |",- "+---------+---------+-------+",- "| 0.00001 | 1.0e-12 | true |",- "| 0.00002 | 2.0e-12 | false |",- "| 0.00002 | 2.0e-12 | false |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00003 | 3.0e-12 | true |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00004 | 4.0e-12 | false |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "| 0.00005 | 5.0e-12 | true |",- "+---------+---------+-------+",- ];-- assert_batches_eq!(expected, &results);-- Ok(())-}--#[tokio::test]-async fn select_qualified_wildcard_join() -> Result<()> {- let ctx = create_join_context("t1_id", "t2_id", true)?;- let sql =- "SELECT tb1.*, tb2.* FROM t1 tb1 JOIN t2 tb2 ON t2_id = t1_id ORDER BY t1_id";- let expected = vec![- "+-------+---------+--------+-------+---------+--------+",- "| t1_id | t1_name | t1_int | t2_id | t2_name | t2_int |",- "+-------+---------+--------+-------+---------+--------+",- "| 11 | a | 1 | 11 | z | 3 |",- "| 22 | b | 2 | 22 | y | 1 |",- "| 44 | d | 4 | 44 | x | 3 |",- "+-------+---------+--------+-------+---------+--------+",- ];-- let results = execute_to_batches(&ctx, sql).await;-- assert_batches_eq!(expected, &results);-- Ok(())-}--#[tokio::test]-async fn select_non_alias_qualified_wildcard_join() -> Result<()> {- let ctx = create_join_context("t1_id", "t2_id", true)?;- let sql = "SELECT t1.*, tb2.* FROM t1 JOIN t2 tb2 ON t2_id = t1_id ORDER BY t1_id";- let expected = vec![- "+-------+---------+--------+-------+---------+--------+",- "| t1_id | t1_name | t1_int | t2_id | t2_name | t2_int |",- "+-------+---------+--------+-------+---------+--------+",- "| 11 | a | 1 | 11 | z | 3 |",- "| 22 | b | 2 | 22 | y | 1 |",- "| 44 | d | 4 | 44 | x | 3 |",- "+-------+---------+--------+-------+---------+--------+",- ];-- let results = execute_to_batches(&ctx, sql).await;-- assert_batches_eq!(expected, &results);-- Ok(())-}--#[tokio::test]-async fn select_wrong_qualified_wildcard() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_simple_csv(&ctx).await?;-- let sql = "SELECT agg.* FROM aggregate_simple order by c1";- let err = ctx.sql(sql).await.unwrap_err().to_string();- assert_eq!(err, "Error during planning: Invalid qualifier agg");-- Ok(())-}diff --git a/datafusion/core/tests/sqllogictests/test_files/wildcard.slt b/datafusion/core/tests/sqllogictests/test_files/wildcard.sltnew file mode 100644index 0000000000..cc43ff4376--- /dev/null+++ b/datafusion/core/tests/sqllogictests/test_files/wildcard.slt@@ -0,0 +1,122 @@+# 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.+++# create t1 table+statement ok+CREATE TABLE t1(t1_id INT, t1_name TEXT, t1_int INT) AS VALUES+(11, 'a', 1),+(22, 'b', 2),+(33, 'c', 3),+(44, 'd', 4);++# create t2 table+statement ok+CREATE TABLE t2(t2_id INT, t2_name TEXT, t2_int INT) AS VALUES+(11, 'z', 3),+(22, 'y', 1),+(44, 'x', 3),+(55, 'w', 3);++# create aggregate_simple table+statement ok+CREATE EXTERNAL TABLE aggregate_simple (+ c1 REAL NOT NULL,+ c2 DOUBLE NOT NULL,+ c3 BOOLEAN NOT NULL,+)+STORED AS CSV+WITH HEADER ROW+LOCATION 'tests/data/aggregate_simple.csv'+++##########+## Wildcard Tests+##########++# select_qualified_wildcard+query RRB nosort+SELECT agg.* FROM aggregate_simple as agg ORDER BY c1+----+0.00001 0.000000000001 true+0.00002 0.000000000002 false+0.00002 0.000000000002 false+0.00003 0.000000000003 true+0.00003 0.000000000003 true+0.00003 0.000000000003 true+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true++# select_non_alias_qualified_wildcard+query RRB nosort+SELECT aggregate_simple.* FROM aggregate_simple ORDER BY c1+----+0.00001 0.000000000001 true+0.00002 0.000000000002 false+0.00002 0.000000000002 false+0.00003 0.000000000003 true+0.00003 0.000000000003 true+0.00003 0.000000000003 true+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00004 0.000000000004 false+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true+0.00005 0.000000000005 true++# select_qualified_wildcard_join+query ITIITI nosort+SELECT tb1.*, tb2.* FROM t1 tb1 JOIN t2 tb2 ON t2_id = t1_id ORDER BY t1_id+----+11 a 1 11 z 3+22 b 2 22 y 1+44 d 4 44 x 3++# select_non_alias_qualified_wildcard_join+query ITIITI nosort+SELECT t1.*, tb2.* FROM t1 JOIN t2 tb2 ON t2_id = t1_id ORDER BY t1_id+----+11 a 1 11 z 3+22 b 2 22 y 1+44 d 4 44 x 3++# select_wrong_qualified_wildcard+statement error Error during planning: Invalid qualifier agg+SELECT agg.* FROM aggregate_simple ORDER BY c1++########+# Clean up after the test+########++statement ok+DROP TABLE t1;++statement ok+DROP TABLE t2;++statement ok+DROP TABLE aggregate_simple;