-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: customize column default values for external tables #8415
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,11 +217,10 @@ async fn roundtrip_custom_memory_tables() -> Result<()> { | |
async fn roundtrip_custom_listing_tables() -> Result<()> { | ||
let ctx = SessionContext::new(); | ||
|
||
// Make sure during round-trip, constraint information is preserved | ||
let query = "CREATE EXTERNAL TABLE multiple_ordered_table_with_pk ( | ||
a0 INTEGER, | ||
a INTEGER, | ||
b INTEGER, | ||
a INTEGER DEFAULT 1*2 + 3, | ||
b INTEGER DEFAULT NULL, | ||
c INTEGER, | ||
d INTEGER, | ||
primary key(c) | ||
|
@@ -232,11 +231,13 @@ 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()?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It always returned an EmptyRelation before, and did not achieve the testing purpose as expected. |
||
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. Make sure during round-trip, | ||
// information like constraints, column defaults, and other aspects of the plan are preserved. | ||
assert_eq!(plan, logical_round_trip); | ||
|
||
Ok(()) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,6 +382,27 @@ select a,b,c,d from test_column_defaults | |
1 10 100 ABC | ||
NULL 20 500 default_text | ||
|
||
# fill the timestamp column with default value `now()` again, it should be different from the previous one | ||
query IIITP | ||
insert into test_column_defaults(a, b, c, d) values(2, 20, 200, 'DEF') | ||
---- | ||
1 | ||
|
||
# Ensure that the default expression `now()` is evaluated during insertion, not optimized away. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
# Rows are inserted during different time, so their timestamp values should be different. | ||
query I rowsort | ||
select count(distinct e) from test_column_defaults | ||
---- | ||
3 | ||
|
||
# Expect all rows to be true as now() was inserted into the table | ||
query B rowsort | ||
select e < now() from test_column_defaults | ||
---- | ||
true | ||
true | ||
true | ||
|
||
statement ok | ||
drop table test_column_defaults | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced
hashbrown::HashMap
in #8283, now I am replacing it withstd::collections::HashMap
.