alamb commented on code in PR #4194:
URL: https://github.com/apache/arrow-datafusion/pull/4194#discussion_r1024363641
##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -49,6 +49,76 @@ async fn create_table_as() -> Result<()> {
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) \
Review Comment:

##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -49,6 +49,76 @@ async fn create_table_as() -> Result<()> {
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) \
Review Comment:
👍
--
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]