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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to