alamb commented on code in PR #7276:
URL: https://github.com/apache/arrow-datafusion/pull/7276#discussion_r1293753787
##########
datafusion/sql/tests/sql_integration.rs:
##########
@@ -1796,11 +1796,15 @@ fn create_external_table_with_compression_type() {
#[test]
fn create_external_table_parquet() {
let sql = "CREATE EXTERNAL TABLE t(c1 int) STORED AS PARQUET LOCATION
'foo.parquet'";
- let err = logical_plan(sql).expect_err("query should have failed");
- assert_eq!(
- "Plan(\"Column definitions can not be specified for PARQUET files.\")",
- format!("{err:?}")
- );
+ let expected = "CreateExternalTable: Bare { table: \"t\" }";
+ quick_test(sql, expected);
+}
+
+#[test]
+fn create_external_table_parquet_sort_order() {
+ let sql = "create external table foo(a varchar, b varchar, c timestamp)
stored as parquet location '/tmp/foo' with order (c)";
+ let expected = "CreateExternalTable: Bare { table: \"foo\" }";
+ quick_test(sql, expected);
Review Comment:
🤔 I tried to run this locally it doesn't quite work
```
❯ create external table t(x integer, y varchar) stored as parquet location
'/tmp/foo' with order (x);
0 rows in set. Query took 0.001 seconds.
❯ select * from t;
0 rows in set. Query took 0.002 seconds.
❯ insert into t values (1, 'foo'), (2, 'bar');
This feature is not implemented: Writing to a sorted listing table via
insert into is not supported yet. To write to this table in the meantime,
register an equivalent table with file_sort_order = vec![]
```
But it is getting very close.
##########
datafusion/core/src/datasource/listing/table.rs:
##########
@@ -2096,4 +2230,64 @@ mod tests {
// Return Ok if the function
Ok(())
}
+
+ /// tests insert into with end to end sql
+ /// create external table + insert into statements
+ async fn helper_test_insert_into_sql(
Review Comment:
I think we could use sqllogictest to test this as well --
Perhaps add to
https://github.com/apache/arrow-datafusion/blob/main/datafusion/core/tests/sqllogictests/test_files/insert.slt
I can't remember how temporary directories work in sqllogictests though
##########
datafusion/sql/tests/sql_integration.rs:
##########
@@ -1796,11 +1796,15 @@ fn create_external_table_with_compression_type() {
#[test]
fn create_external_table_parquet() {
let sql = "CREATE EXTERNAL TABLE t(c1 int) STORED AS PARQUET LOCATION
'foo.parquet'";
- let err = logical_plan(sql).expect_err("query should have failed");
- assert_eq!(
- "Plan(\"Column definitions can not be specified for PARQUET files.\")",
- format!("{err:?}")
- );
+ let expected = "CreateExternalTable: Bare { table: \"t\" }";
+ quick_test(sql, expected);
+}
+
+#[test]
+fn create_external_table_parquet_sort_order() {
+ let sql = "create external table foo(a varchar, b varchar, c timestamp)
stored as parquet location '/tmp/foo' with order (c)";
+ let expected = "CreateExternalTable: Bare { table: \"foo\" }";
+ quick_test(sql, expected);
Review Comment:
🤔 I tried to run this locally it doesn't quite work
```
❯ create external table t(x integer, y varchar) stored as parquet location
'/tmp/foo' with order (x);
0 rows in set. Query took 0.001 seconds.
❯ select * from t;
0 rows in set. Query took 0.002 seconds.
❯ insert into t values (1, 'foo'), (2, 'bar');
This feature is not implemented: Writing to a sorted listing table via
insert into is not supported yet. To write to this table in the meantime,
register an equivalent table with file_sort_order = vec![]
```
But it is getting very close.
--
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]