-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18394][SQL] Make an AttributeSet.toSeq output order consistent #18959
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 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,4 +78,34 @@ class AttributeSetSuite extends SparkFunSuite { | |
| assert(aSet == aSet) | ||
| assert(aSet == AttributeSet(aUpper :: Nil)) | ||
| } | ||
|
|
||
| test("SPARK-18394 keep a deterministic output order along with attribute names") { | ||
|
||
| val attrSeqA = { | ||
| val attr1 = AttributeReference("c1", IntegerType)(exprId = ExprId(1098)) | ||
| val attr2 = AttributeReference("c2", IntegerType)(exprId = ExprId(107)) | ||
| val attr3 = AttributeReference("c3", IntegerType)(exprId = ExprId(838)) | ||
| val attrSetA = AttributeSet(attr1 :: attr2 :: attr3 :: Nil) | ||
|
|
||
| val attr4 = AttributeReference("c4", IntegerType)(exprId = ExprId(389)) | ||
| val attr5 = AttributeReference("c5", IntegerType)(exprId = ExprId(89329)) | ||
|
|
||
| val attrSetB = AttributeSet(attr4 :: attr5 :: Nil) | ||
| (attrSetA ++ attrSetB).toSeq.map(_.name) | ||
| } | ||
|
|
||
| val attrSeqB = { | ||
| val attr1 = AttributeReference("c1", IntegerType)(exprId = ExprId(392)) | ||
| val attr2 = AttributeReference("c2", IntegerType)(exprId = ExprId(92)) | ||
| val attr3 = AttributeReference("c3", IntegerType)(exprId = ExprId(87)) | ||
| val attrSetA = AttributeSet(attr1 :: attr2 :: attr3 :: Nil) | ||
|
|
||
| val attr4 = AttributeReference("c4", IntegerType)(exprId = ExprId(9023920)) | ||
| val attr5 = AttributeReference("c5", IntegerType)(exprId = ExprId(522)) | ||
| val attrSetB = AttributeSet(attr4 :: attr5 :: Nil) | ||
|
|
||
| (attrSetA ++ attrSetB).toSeq.map(_.name) | ||
| } | ||
|
|
||
| assert(attrSeqA === attrSeqB) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,7 +162,8 @@ class PruningSuite extends HiveComparisonTest with BeforeAndAfter { | |
| }.head | ||
|
|
||
| assert(actualOutputColumns === expectedOutputColumns, "Output columns mismatch") | ||
| assert(actualScannedColumns === expectedScannedColumns, "Scanned columns mismatch") | ||
| assert(actualScannedColumns.sorted === expectedScannedColumns.sorted, | ||
|
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. Could you add a comment to explain where we call |
||
| "Scanned columns mismatch") | ||
|
|
||
| val actualPartitions = actualPartValues.map(_.asScala.mkString(",")).sorted | ||
| val expectedPartitions = expectedPartValues.map(_.mkString(",")).sorted | ||
|
|
||
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.
If it needs to be a Seq, then should the
toArraybetoSeq? maybe I missed way it has to be an array firstThere 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.
Yea, as you suggested, I initially did so. But, I just kept the original code cuz I was afraid this change wrongly affected the others. cc: @marmbrus
Uh oh!
There was an error while loading. Please reload this page.
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 thought
mapshould always return a strict collection. I think it is safe to sort immediately after that.Uh oh!
There was an error while loading. Please reload this page.
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.
ok, I'll fix in that way. Thanks!