You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/12/12 21:27:09 UTC

[arrow-datafusion] branch master updated: Move subset of select tests to sqllogic (#4583)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d3065e52 Move subset of select tests to sqllogic (#4583)
4d3065e52 is described below

commit 4d3065e5262d660f3ffcb77cbcc4b84d46dee3c9
Author: Ajaya Agrawal <aj...@gmail.com>
AuthorDate: Tue Dec 13 02:57:04 2022 +0530

    Move subset of select tests to sqllogic (#4583)
    
    * Move subset of select tests to sqllogic
    
    * add the slt file
---
 datafusion/core/tests/sql/select.rs                | 75 ----------------------
 datafusion/core/tests/sqllogictests/src/main.rs    |  2 +-
 .../core/tests/sqllogictests/test_files/select.slt | 58 +++++++++++++++++
 3 files changed, 59 insertions(+), 76 deletions(-)

diff --git a/datafusion/core/tests/sql/select.rs b/datafusion/core/tests/sql/select.rs
index c82eee7d0..35d8dc6d6 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.rs
index 3d2fe492c..e8c44babe 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 000000000..2d8209fb7
--- /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