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 @@ -116,7 +116,8 @@ object GeneratedColumn {
val allowedBaseColumns = schema
.filterNot(_.name == fieldName) // Can't reference itself
.filterNot(isGeneratedColumn) // Can't reference other generated columns
val relation = new LocalRelation(StructType(allowedBaseColumns).toAttributes)
val relation = new LocalRelation(CharVarcharUtils.replaceCharVarcharWithStringInSchema(
StructType(allowedBaseColumns)).toAttributes)
val plan = try {
val analyzer: Analyzer = GeneratedColumnAnalyzer
val analyzed = analyzer.execute(Project(Seq(Alias(parsed, fieldName)()), relation))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,24 @@ class DataSourceV2SQLSuiteV1Filter
)
}

test("SPARK-44313: generation expression validation passes when there is a char/varchar column") {
val tblName = "my_tab"
// InMemoryTableCatalog.capabilities() = {SUPPORTS_CREATE_TABLE_WITH_GENERATED_COLUMNS}
for (charVarCharCol <- Seq("name VARCHAR(64)", "name CHAR(64)")) {
withTable(s"testcat.$tblName") {
sql(
s"""
|CREATE TABLE testcat.$tblName(
| $charVarCharCol,
| tstamp TIMESTAMP,
| tstamp_date DATE GENERATED ALWAYS AS (CAST(tstamp AS DATE))
|) USING foo
|""".stripMargin)
assert(catalog("testcat").asTableCatalog.tableExists(Identifier.of(Array(), tblName)))
}
}
}

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