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

[HUDI-4183] Fix using HoodieCatalog to create non-hudi tables #5743

Merged
merged 1 commit into from
Jun 3, 2022
Merged
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 @@ -781,4 +781,35 @@ class TestCreateTable extends HoodieSparkSqlTestBase {
val tablePath = s"${dbPath}/${tableName}"
assertResult(false)(existsPath(tablePath))
}

test("Test Create Non-Hudi Table(Parquet Table)") {
val databaseName = "test_database"
spark.sql(s"create database if not exists $databaseName")
spark.sql(s"use $databaseName")

val tableName = generateTableName
// Create a managed table
spark.sql(
s"""
| create table $tableName (
| id int,
| name string,
| price double,
| ts long
| ) using parquet
""".stripMargin)
val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier(tableName))
assertResult(tableName)(table.identifier.table)
assertResult("parquet")(table.provider.get)
assertResult(CatalogTableType.MANAGED)(table.tableType)
assertResult(
Seq(
StructField("id", IntegerType),
StructField("name", StringType),
StructField("price", DoubleType),
StructField("ts", LongType))
)(table.schema.fields)

spark.sql("use default")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ class HoodieCatalog extends DelegatingCatalogExtension
schema: StructType,
partitions: Array[Transform],
properties: util.Map[String, String]): Table = {
val locUriAndTableType = deduceTableLocationURIAndTableType(ident, properties)
createHoodieTable(ident, schema, locUriAndTableType, partitions, properties,
Map.empty, Option.empty, TableCreationMode.CREATE)
if (sparkAdapter.isHoodieTable(properties)) {
val locUriAndTableType = deduceTableLocationURIAndTableType(ident, properties)
createHoodieTable(ident, schema, locUriAndTableType, partitions, properties,
Map.empty, Option.empty, TableCreationMode.CREATE)
} else {
super.createTable(ident, schema, partitions, properties)
}
}

override def tableExists(ident: Identifier): Boolean = super.tableExists(ident)
Expand Down