You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/06 22:06:28 UTC

[GitHub] [arrow-datafusion] alamb opened a new pull request, #4535: Move some create/drop tests to `ddl.slt`

alamb opened a new pull request, #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535

   
   Draft as it builds on https://github.com/apache/arrow-datafusion/pull/4530
   
   # Which issue does this PR close?
   
   Part of https://github.com/apache/arrow-datafusion/issues/4495
   
   
   # Rationale for this change
   
   In https://github.com/apache/arrow-datafusion/issues/4495 we are porting tests from rust to sqllogictest for speed and consistency
   
   
   
   
   # What changes are included in this PR?
   Port some rust based tests in `create_drop.rs` to sqllogictests
   
   # Are these changes tested?
   Yes
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1042637240


##########
datafusion/core/tests/data/partitioned_table/c_date=2018-11-13/timestamps.csv:
##########
@@ -0,0 +1,2 @@
+Jorge,2018-12-13T12:12:10.011Z

Review Comment:
   These files used to be generated programatically in Rust, instead I have checked them in for the tests



##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   One difference is that .slt files don't seem to offer a way to expect a certain error message (seemingly by design). I am not sure if you have any thoughts / experience on this @xudong963 



##########
datafusion/core/tests/sqllogictests/test_files/ddl.slt:
##########
@@ -182,5 +182,234 @@ DROP VIEW foo, bar;
 statement ok
 DROP VIEW foo;
 
+# Ok to drop

Review Comment:
   I think the SLT files are much easier to add / work with ❤️ 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1044611807


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   Sweet -- hank you @xxchan  I will update these tests to use that syntax



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] xudong963 commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
xudong963 commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1044301771


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   I think it can be supported in sqllogictest-rs. 
   
   Currently, databend has written its own python version of the logictest framework, which is able to add error messages, such as `statement error 1006`: 1006 is errorcode.
   
   So I think it's a reasonable feature ~  ping @xxchan.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1044728220


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   Here is an improvement to fix the messages: https://github.com/apache/arrow-datafusion/pull/4572



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] xxchan commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
xxchan commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1044307741


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   We do support error messages:
   
   `statement error <regexp>` and `query error <regexp>`
   
   example can be found here https://github.com/risinglightdb/sqllogictest-rs/blob/main/examples/basic/basic.slt#L20



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535#discussion_r1044642558


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -15,427 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::fs::create_dir_all;
-use std::io::Write;
-
 use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
 use datafusion::test_util::TestTableFactory;
-use tempfile::TempDir;
 
 use super::*;
 
-#[tokio::test]
-async fn create_table_as() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+",
-        "| c1      | c2             | c3   |",
-        "+---------+----------------+------+",
-        "| 0.00001 | 0.000000000001 | true |",
-        "+---------+----------------+------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT *,c3 as c4_tmp FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table order by c1 LIMIT 1";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+----------------+------+----+",
-        "| c1      | c2             | c3   | c4 |",
-        "+---------+----------------+------+----+",
-        "| 0.00001 | 0.000000000001 | true | 1  |",
-        "+---------+----------------+------+----+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_select_mismatch() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table(c1 float, c2 double, c3 boolean, c4 varchar) \
-    AS SELECT * FROM aggregate_simple";
-    let expected_err = ctx.sql(sql).await.unwrap_err();
-    assert_contains!(
-        expected_err.to_string(),
-        "Mismatch: 4 columns specified, but result has 3 columns"
-    );
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_table_with_schema_as_values() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql =
-        "CREATE TABLE my_table(c1 int, c2 float, c3 varchar) AS VALUES(1, 2, 'hello')";
-    ctx.sql(sql).await.unwrap();
-
-    let sql_all = "SELECT * FROM my_table";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+----+----+-------+",
-        "| c1 | c2 | c3    |",
-        "+----+----+-------+",
-        "| 1  | 2  | hello |",
-        "+----+----+-------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn create_or_replace_table_as() -> Result<()> {
-    // the information schema used to introduce cyclic Arcs
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-
-    // Create table
-    let result = ctx
-        .sql("CREATE TABLE y AS VALUES (1,2),(3,4)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-    assert!(result.is_empty());
-
-    // Replace table
-    ctx.sql("CREATE OR REPLACE TABLE y AS VALUES (5,6)")
-        .await
-        .unwrap()
-        .collect()
-        .await
-        .unwrap();
-
-    let sql_all = "SELECT * FROM y";
-    let results_all = execute_to_batches(&ctx, sql_all).await;
-
-    let expected = vec![
-        "+---------+---------+",
-        "| column1 | column2 |",
-        "+---------+---------+",
-        "| 5       | 6       |",
-        "+---------+---------+",
-    ];
-
-    assert_batches_eq!(expected, &results_all);
-
-    // 'IF NOT EXISTS' cannot coexist with 'REPLACE'
-    let result = ctx
-        .sql("CREATE OR REPLACE TABLE if not exists y AS VALUES (7,8)")
-        .await;
-    assert!(
-        result.is_err(),
-        "'IF NOT EXISTS' cannot coexist with 'REPLACE'"
-    );
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_table() -> Result<()> {
-    let ctx = SessionContext::new();
-    register_aggregate_simple_csv(&ctx).await?;
-
-    let sql = "CREATE TABLE my_table AS SELECT * FROM aggregate_simple";
-    ctx.sql(sql).await.unwrap();
-
-    let sql = "DROP TABLE my_table";
-    ctx.sql(sql).await.unwrap();
-
-    let result = ctx.table("my_table");
-    assert!(result.is_err(), "drop table should deregister table.");
-
-    let sql = "DROP TABLE IF EXISTS my_table";
-    ctx.sql(sql).await.unwrap();
-
-    Ok(())
-}
-
-#[tokio::test]
-async fn drop_view() -> Result<()> {
-    let ctx =
-        SessionContext::with_config(SessionConfig::new().with_information_schema(true));
-    plan_and_collect(&ctx, "CREATE VIEW v AS SELECT 1").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert_eq!(rb[0].num_rows(), 1);
-
-    plan_and_collect(&ctx, "DROP VIEW v").await?;
-    let rb = plan_and_collect(
-        &ctx,
-        "select * from information_schema.tables where table_name = 'v' and table_type = 'VIEW'",
-    )
-    .await?;
-    assert!(rb.is_empty());
-    Ok(())
-}
-
-#[tokio::test]
-#[should_panic(expected = "doesn't exist")]

Review Comment:
   I added the expected messages in 6be3662b6 -- very cool! It was good enough that I see a few bugs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #4535: Move some create/drop tests to `ddl.slt`

Posted by GitBox <gi...@apache.org>.
alamb merged PR #4535:
URL: https://github.com/apache/arrow-datafusion/pull/4535


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org