Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.3.0
Description
We're no longer picking up x = 2 as a constraint from something like df.withColumn("x", lit(2))
The unit test below succeeds in branch-2.2:
test("constraints should be inferred from aliased literals") { val originalLeft = testRelation.subquery('left).as("left") val optimizedLeft = testRelation.subquery('left).where(IsNotNull('a) && 'a <=> 2).as("left") val right = Project(Seq(Literal(2).as("two")), testRelation.subquery('right)).as("right") val condition = Some("left.a".attr === "right.two".attr) val original = originalLeft.join(right, Inner, condition) val correct = optimizedLeft.join(right, Inner, condition) comparePlans(Optimize.execute(original.analyze), correct.analyze) }
but fails in branch-2.3 with:
== FAIL: Plans do not match === 'Join Inner, (two#0 = a#0) 'Join Inner, (two#0 = a#0) !:- Filter isnotnull(a#0) :- Filter ((2 <=> a#0) && isnotnull(a#0)) : +- LocalRelation <empty>, [a#0, b#0, c#0] : +- LocalRelation <empty>, [a#0, b#0, c#0] +- Project [2 AS two#0] +- Project [2 AS two#0] +- LocalRelation <empty>, [a#0, b#0, c#0] +- LocalRelation <empty>, [a#0, b#0, c#0]