-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-4629] Create hive table from existing hoodie table failed when the table schema is not defined #6409
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
base: master
Are you sure you want to change the base?
[HUDI-4629] Create hive table from existing hoodie table failed when the table schema is not defined #6409
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,17 @@ class HoodieCatalogTable(val spark: SparkSession, var table: CatalogTable) exten | |
| /** | ||
| * Table schema | ||
| */ | ||
| lazy val tableSchema: StructType = table.schema | ||
| lazy val tableSchema: StructType = if (table.schema.nonEmpty) { | ||
| table.schema | ||
| } else { | ||
| val schemaFromMetaOpt = loadTableSchemaByMetaClient() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this already handled in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jinxing64 can you also have a look pls? given this is based on your previous change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (schemaFromMetaOpt.nonEmpty) { | ||
| schemaFromMetaOpt.get | ||
| } else { | ||
| throw new AnalysisException( | ||
| s"Missing schema fields when applying CREATE TABLE clause for $catalogTableName") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The schema without hoodie meta fields | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to call
loadTableSchemaByMetaClientdirectly without having to decide iftable.schemais empty.Parsing the metadata on spark does not need to depend on the meta from metastore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YannByron The
table.schemais not obtained from the hive metastore, but is specified by the user. Only when the user does not specify a schema, we can parse and obtain the schema from the file through the methodloadTableSchemaByMetaClient