Skip to content
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ trait CheckAnalysis extends PredicateHelper {
def ordinalNumber(i: Int): String = i match {
case 0 => "first"
case 1 => "second"
case i => s"${i}th"
case 2 => "third"
case i => s"${i + 1}th"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehehe, nice catch ;)

}
val ref = dataTypes(operator.children.head)
operator.children.tail.zipWithIndex.foreach { case (child, ti) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,4 +831,77 @@ class AnalysisSuite extends AnalysisTest with Matchers {
}
}
}

test("SPARK-32131 Fix wrong column index when we have more than two columns" +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: SPARK-32131 -> SPARK-32131:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks maropu ,btw, I did not see the test build start to build, do you know why?

" during union and set operations" ) {
val firstTable = LocalRelation(
AttributeReference("a", StringType)(),
AttributeReference("b", DoubleType)(),
AttributeReference("c", IntegerType)(),
AttributeReference("d", FloatType)())

val secondTable = LocalRelation(
AttributeReference("a", StringType)(),
AttributeReference("b", TimestampType)(),
AttributeReference("c", IntegerType)(),
AttributeReference("d", FloatType)())

val thirdTable = LocalRelation(
AttributeReference("a", StringType)(),
AttributeReference("b", DoubleType)(),
AttributeReference("c", TimestampType)(),
AttributeReference("d", FloatType)())

val fourthTable = LocalRelation(
AttributeReference("a", StringType)(),
AttributeReference("b", DoubleType)(),
AttributeReference("c", IntegerType)(),
AttributeReference("d", TimestampType)())

val a1 = firstTable.output(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GuoPhilipse Variables a1, b1, c1, d1 not used ? Were you planning to use it in the test later ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

em,,,let me remove it

val b1 = firstTable.output(1)
val c1 = firstTable.output(2)
val d1 = firstTable.output(3)

val a2 = secondTable.output(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

val b2 = secondTable.output(1)
val c2 = secondTable.output(2)
val d2 = secondTable.output(3)

val a3 = thirdTable.output(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

val b3 = thirdTable.output(1)
val c3 = thirdTable.output(2)
val d3 = thirdTable.output(3)

val a4 = fourthTable.output(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dilipbiswal for your review.

val b4 = fourthTable.output(1)
val c4 = fourthTable.output(2)
val d4 = fourthTable.output(3)

val r1 = Union(firstTable, secondTable)
val r2 = Union(firstTable, thirdTable)
val r3 = Union(firstTable, fourthTable)
val r4 = Except(firstTable, secondTable, isAll = false)
val r5 = Intersect(firstTable, secondTable, isAll = false)

assertAnalysisError(r1,
Seq("Union can only be performed on tables with the compatible column types. " +
"timestamp <> double at the second column of the second table"))

assertAnalysisError(r2,
Seq("Union can only be performed on tables with the compatible column types. " +
"timestamp <> int at the third column of the second table"))

assertAnalysisError(r3,
Seq("Union can only be performed on tables with the compatible column types. " +
"timestamp <> float at the 4th column of the second table"))

assertAnalysisError(r4,
Seq("Except can only be performed on tables with the compatible column types. " +
"timestamp <> double at the second column of the second table"))

assertAnalysisError(r5,
Seq("Intersect can only be performed on tables with the compatible column types. " +
"timestamp <> double at the second column of the second table"))
}
}