Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -127,7 +127,9 @@ trait AnalysisHelper extends QueryPlan[LogicalPlan] { self: LogicalPlan =>
rule: PartialFunction[LogicalPlan, (LogicalPlan, Seq[(Attribute, Attribute)])])
: LogicalPlan = {
if (!analyzed) {
transformUpWithNewOutput(rule, skipCond = _.analyzed, canGetOutput = _.resolved)
AnalysisHelper.allowInvokingTransformsInAnalyzer {
transformUpWithNewOutput(rule, skipCond = _.analyzed, canGetOutput = _.resolved)
}
} else {
self
}
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 ") {
Copy link
Member

Choose a reason for hiding this comment

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

branch-3.0 has the same issue? The branch does not have PaddingAndLengthCheckForCharVarchar though.

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove the unnecessary space in the end: in correlated sub query ") -> in correlated sub query")

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

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),
Copy link
Member

Choose a reason for hiding this comment

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

nit: | WHERE 'a' IN -> |WHERE 'a' IN?

Row("c"))
}
}
}

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