alamb commented on code in PR #8415:
URL: https://github.com/apache/arrow-datafusion/pull/8415#discussion_r1416240577
##########
datafusion/sqllogictest/test_files/insert_to_external.slt:
##########
@@ -543,3 +543,48 @@ select * from table_without_values;
statement ok
drop table table_without_values;
+
+
+### Test for specifying column's default value
+
+statement ok
+CREATE EXTERNAL TABLE test_column_defaults(
+ a int,
+ b int not null default null,
+ c int default 100*2+300,
+ d text default lower('DEFAULT_TEXT'),
+ e timestamp default now()
+) STORED AS parquet
+LOCATION 'test_files/scratch/insert_to_external/external_parquet_table_q6'
+OPTIONS (create_local_path 'true');
+
+query IIITP
+insert into test_column_defaults values(1, 10, 100, 'ABC', now())
+----
+1
+
+statement error DataFusion error: Execution error: Invalid batch column at '1'
has null but schema specifies non-nullable
+insert into test_column_defaults(a) values(2)
+
+query IIITP
+insert into test_column_defaults(b) values(20)
+----
+1
+
+query IIIT rowsort
+select a,b,c,d from test_column_defaults
Review Comment:
Could you also add a test that the value of `now()` was set?
Maybe something basic like
```sql
-- Expect all rows to be true as now() was inserted into the table
select e < now() from test_column_defaults
```
?
##########
datafusion/proto/tests/cases/roundtrip_logical_plan.rs:
##########
@@ -232,11 +232,12 @@ async fn roundtrip_custom_listing_tables() -> Result<()> {
WITH ORDER (c ASC)
LOCATION '../core/tests/data/window_2.csv';";
- let plan = ctx.sql(query).await?.into_optimized_plan()?;
+ let plan = ctx.state().create_logical_plan(query).await?;
let bytes = logical_plan_to_bytes(&plan)?;
let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?;
- assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}"));
+ // Use exact matching to verify everything, such as column defaults
Review Comment:
Nice -- I think this check predated the `LogicalPlan::PartialEq`
implementation. I think this is a nice change
--
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]