-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add primary key information to CreateMemoryTable LogicalPlan node #5835
Conversation
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.
Thanks @avantgardnerio! Looks good overall, I left some minor comments.
Also, I find it easier to review without whitespace: https://github.com/apache/arrow-datafusion/pull/5835/files?diff=split&w=1
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.
Thanks @avantgardnerio -- this is looking good
Okay fellas, I think this is ready... |
fn plan_create_table_with_pk() { | ||
let sql = "create table person (id int, name string, primary key(id))"; | ||
let plan = r#" | ||
CreateMemoryTable: Bare { table: "person" } primary_key=[id] |
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.
Should show PK
fn plan_create_table_no_pk() { | ||
let sql = "create table person (id int, name string)"; | ||
let plan = r#" | ||
CreateMemoryTable: Bare { table: "person" } |
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.
Does not change existing behavior if no PK
} | ||
|
||
#[test] | ||
#[should_panic(expected = "Non-primary unique constraints are not supported")] |
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.
Unhanded syntax causes errors.
Which issue does this PR close?
Closes #5834.
Rationale for this change
As a developer building a database atop DataFusion, it would be useful to have knowledge of primary keys retained in the LogicalPlan.
What changes are included in this PR?
A new
primary_key
field onLogicalPlan::CreateMemoryTable
Are these changes tested?
Sort of - there's a test that broke before, but I couldn't figure out what prints this LogicalPlan node, so I wasn't able to add the pk info to the
Debug
trait and assert that.Are there any user-facing changes?
create table
statements that used to fail (e.g. withprimary key
clauses) will now not fail. I'm not sure if that's an issue for anyone.