feat: customize column default values for external tables#8415
Merged
alamb merged 3 commits intoapache:mainfrom Dec 6, 2023
Merged
feat: customize column default values for external tables#8415alamb merged 3 commits intoapache:mainfrom
alamb merged 3 commits intoapache:mainfrom
Conversation
jonahgao
commented
Dec 4, 2023
| WITH ORDER (c ASC) | ||
| LOCATION '../core/tests/data/window_2.csv';"; | ||
|
|
||
| let plan = ctx.sql(query).await?.into_optimized_plan()?; |
Member
Author
There was a problem hiding this comment.
It always returned an EmptyRelation before, and did not achieve the testing purpose as expected.
jonahgao
commented
Dec 4, 2023
| use hashbrown::HashMap; | ||
| use log::debug; | ||
| use std::any::Any; | ||
| use std::collections::HashMap; |
Member
Author
There was a problem hiding this comment.
I introduced hashbrown::HashMap in #8283, now I am replacing it with std::collections::HashMap.
7 tasks
alamb
approved these changes
Dec 5, 2023
| 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 |
Contributor
There was a problem hiding this comment.
Nice -- I think this check predated the LogicalPlan::PartialEq implementation. I think this is a nice change
| 1 | ||
|
|
||
| query IIIT rowsort | ||
| select a,b,c,d from test_column_defaults |
Contributor
There was a problem hiding this comment.
Could you also add a test that the value of now() was set?
Maybe something basic like
-- Expect all rows to be true as now() was inserted into the table
select e < now() from test_column_defaults?
alamb
approved these changes
Dec 6, 2023
| ---- | ||
| 1 | ||
|
|
||
| # Ensure that the default expression `now()` is evaluated during insertion, not optimized away. |
appletreeisyellow
pushed a commit
to appletreeisyellow/datafusion
that referenced
this pull request
Dec 15, 2023
* feat: customize column default values for external tables * fix test * tests from reviewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
It is a continuation of #8283.
Rationale for this change
We previously implemented customizing column default values on memory tables, and this PR implements it for external tables.
What changes are included in this PR?
Support customizing column default values for external tables.
This feature will take effect when inserting.
Are these changes tested?
Yes
Are there any user-facing changes?
Yes.
Add a new field
column_defaultsinDdlStatement::CreateExternalTable.