-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25371][SQL] struct() should allow being called with 0 args #22373
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,4 +256,9 @@ class VectorAssemblerSuite | |
| assert(runWithMetadata("keep", additional_filter = "id1 > 2").count() == 4) | ||
| } | ||
|
|
||
| test("SPARK-25371: VectorAssembler with empty inputCols") { | ||
| val vectorAssembler = new VectorAssembler().setInputCols(Array()).setOutputCol("a") | ||
|
Member
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. Is
Member
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. cc @yanboliang and @srowen
Member
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 doesn't sound that useful, but the JIRA suggests this is the behavior in 2.2. It throws a weird error in 2.3. I could imagine just allowing this behavior, or throwing a better exception. Is there a use case for no input? maybe you have some reusable pipeline that is applied to a subset of columns and sometimes it matches nothing. The output is empty but maybe that doesn't matter for whatever purpose it serves... maybe it's assembled with something else afterwards. I could picture a valid use case. |
||
| val output = vectorAssembler.transform(dfWithNullsAndNaNs) | ||
| assert(output.select("a").limit(1).collect().head == Row(Vectors.sparse(0, Seq.empty))) | ||
| } | ||
| } | ||
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.
Do we still need this 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.
I think so, after this patch this test passes, before it doesn't. I think it is helpful to avoid regressions like this in the future.