Skip to content

[SPARK-33992][SQL] override transformUpWithNewOutput to add allowInvokingTransformsInAnalyzer #31013

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

Closed
wants to merge 2 commits into from
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