Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17866][SPARK-17867][SQL] Fix Dataset.dropduplicates - #15427
[SPARK-17866][SPARK-17867][SQL] Fix Dataset.dropduplicates#15427viirya wants to merge 2 commits into
Conversation
SparkQA
commented
Oct 11, 2016
Test build #66724 has finished for PR 15427 at commit
|
viirya
commented
Oct 11, 2016
| attr | ||
| } else { | ||
| Alias(new First(attr).toAggregateExpression(), attr.name)() | ||
| // We should keep the original exprId of the attribute. |
There was a problem hiding this comment.
can you explain why in the comment why we should keep the original exprId? Otherwise this comment is redundant with the code itself.
SparkQA
commented
Oct 12, 2016
Test build #66790 has finished for PR 15427 at commit
|
cloud-fan
commented
Oct 12, 2016
My thoughts:
|
rxin
commented
Oct 12, 2016
|
| // so we call filter instead of find. | ||
| val cols = allColumns.filter(col => resolver(col.name, colName)) | ||
| if (cols.isEmpty) { | ||
| throw new AnalysisException( |
There was a problem hiding this comment.
Dataset.drop is a no-op if the given name doesn't match any column. Should we follow it?
There was a problem hiding this comment.
My thought is:
When an user mistakenly gives wrong column to Dataset.drop, it can be easily found out.
But for Dataset.dropDuplicates, it might be harder to figure out duplicate rows are still there. So to throw an explicit exception looks more proper to me.
cloud-fan
commented
Oct 13, 2016
LGTM, merging to master! |
viirya
commented
Oct 13, 2016
Thanks for review! @rxin@cloud-fan |
## What changes were proposed in this pull request?
Two issues regarding Dataset.dropduplicates:
1. Dataset.dropDuplicates should consider the columns with same column name
We find and get the first resolved attribute from output with the given column name in `Dataset.dropDuplicates`. When we have the more than one columns with the same name. Other columns are put into aggregation columns, instead of grouping columns.
2. Dataset.dropDuplicates should not change the output of child plan
We create new `Alias` with new exprId in `Dataset.dropDuplicates` now. However it causes problem when we want to select the columns as follows:
val ds = Seq(("a", 1), ("a", 2), ("b", 1), ("a", 1)).toDS()
// ds("_2") will cause analysis exception
ds.dropDuplicates("_1").select(ds("_1").as[String], ds("_2").as[Int])
Because the two issues are both related to `Dataset.dropduplicates` and the code changes are not big, so submitting them together as one PR.
## How was this patch tested?
Jenkins tests.
Author: Liang-Chi Hsieh <viirya@gmail.com>
Closesapache#15427 from viirya/fix-dropduplicates.
What changes were proposed in this pull request?
Two issues regarding Dataset.dropduplicates:
Dataset.dropDuplicates should consider the columns with same column name
We find and get the first resolved attribute from output with the given column name in
Dataset.dropDuplicates. When we have the more than one columns with the same name. Other columns are put into aggregation columns, instead of grouping columns.Dataset.dropDuplicates should not change the output of child plan
We create new
Aliaswith new exprId inDataset.dropDuplicatesnow. However it causes problem when we want to select the columns as follows:Because the two issues are both related to
Dataset.dropduplicatesand the code changes are not big, so submitting them together as one PR.How was this patch tested?
Jenkins tests.