-
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
feat: add alias()
method for DataFrame
#14127
Conversation
@@ -2646,3 +2646,58 @@ async fn boolean_dictionary_as_filter() { | |||
|
|||
assert_batches_eq!(expected, &result_df.collect().await.unwrap()); | |||
} | |||
|
|||
#[tokio::test] |
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 @jonahgao, nice PR, I would also add a test with some edge cases like nested alias, empty string alias
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.
Added in af5136b
#[tokio::test] | ||
async fn test_alias_empty() -> Result<()> { | ||
let df = create_test_table("test").await?.alias("")?; | ||
let expected = "SubqueryAlias: [a:Utf8, b:Int32]\ |
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.
We allow creating TableReference
from empty str.
.alias("alias1")? | ||
.alias("alias2")?; | ||
let expected = "SubqueryAlias: alias2 [a:Utf8, b:Int32, one:Int32]\ | ||
\n SubqueryAlias: alias1 [a:Utf8, b:Int32, one:Int32]\ |
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.
This layer is redundant, but SubqueryAlias
es won’t appear in the physical plan
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 @jonahgao -- looks good to me
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.
lgtm thanks @jonahgao
Which issue does this PR close?
Closes #14112.
Rationale for this change
The new
alias()
method applies an alias to an existing DataFrame by wrapping aSubqueryAlias
. It is useful for implementing self-joins.What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
New API.