Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -133,6 +133,15 @@ trait AnalysisHelper extends QueryPlan[LogicalPlan] { self: LogicalPlan =>
}
}

override def transformUpWithNewOutput(
rule: PartialFunction[LogicalPlan, (LogicalPlan, Seq[(Attribute, Attribute)])],
skipCond: LogicalPlan => Boolean,
canGetOutput: LogicalPlan => Boolean): LogicalPlan = {
AnalysisHelper.allowInvokingTransformsInAnalyzer {
super.transformUpWithNewOutput(rule, skipCond, canGetOutput)
}
}

/**
* Recursively transforms the expressions of a tree, skipping nodes that have already
* been analyzed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,21 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
Seq(Row("char(5)"), Row("varchar(3)")))
}
}

test("SPARK-33992: char/varchar resolution in correlated sub query") {
withTable("t1", "t2") {
sql(s"CREATE TABLE t1(v VARCHAR(3), c CHAR(5)) USING $format")
sql(s"CREATE TABLE t2(v VARCHAR(3), c CHAR(5)) USING $format")
sql("INSERT INTO t1 VALUES ('c', 'b')")
sql("INSERT INTO t2 VALUES ('a', 'b')")

checkAnswer(sql(
"""
|SELECT v FROM t1
|WHERE 'a' IN (SELECT v FROM t2 WHERE t1.c = t2.c )""".stripMargin),
Row("c"))
}
}
}

// Some basic char/varchar tests which doesn't rely on table implementation.
Expand Down