Skip to content
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

[SPARK-48709][SQL][3.5] Fix varchar type resolution mismatch for DataSourceV2 CTAS #47103

Closed
wants to merge 1 commit 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 @@ -62,10 +62,11 @@ trait V2WriteCommand extends UnaryCommand with KeepAnalyzedQuery {
table.skipSchemaResolution || (query.output.size == table.output.size &&
query.output.zip(table.output).forall {
case (inAttr, outAttr) =>
val inType = CharVarcharUtils.getRawType(inAttr.metadata).getOrElse(inAttr.dataType)
val outType = CharVarcharUtils.getRawType(outAttr.metadata).getOrElse(outAttr.dataType)
// names and types must match, nullability must be compatible
inAttr.name == outAttr.name &&
DataType.equalsIgnoreCompatibleNullability(inAttr.dataType, outType) &&
DataType.equalsIgnoreCompatibleNullability(inType, outType) &&
(outAttr.nullable || !inAttr.nullable)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,16 @@ class DataSourceV2SQLSuiteV1Filter
}
}

test("SPARK-48709: varchar resolution mismatch for DataSourceV2 CTAS") {
withSQLConf(
SQLConf.STORE_ASSIGNMENT_POLICY.key -> SQLConf.StoreAssignmentPolicy.LEGACY.toString) {
withTable("testcat.ns.t1", "testcat.ns.t2") {
sql("CREATE TABLE testcat.ns.t1 (d1 string, d2 varchar(200)) USING parquet")
sql("CREATE TABLE testcat.ns.t2 USING foo as select * from testcat.ns.t1")
}
}
}

test("ShowCurrentNamespace: basic tests") {
def testShowCurrentNamespace(expectedCatalogName: String, expectedNamespace: String): Unit = {
val schema = new StructType()
Expand Down
Loading