-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[MINOR] follow up HUDI-4178 automatically enable schema evolution when read hoodie table. #5791
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
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 |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ import org.apache.hudi.common.util.StringUtils | |
| import org.apache.hudi.common.util.ValidationUtils.checkState | ||
| import org.apache.hudi.internal.schema.{HoodieSchemaException, InternalSchema} | ||
| import org.apache.hudi.internal.schema.convert.AvroInternalSchemaConverter | ||
| import org.apache.hudi.internal.schema.io.FileBasedInternalSchemaStorageManager | ||
| import org.apache.hudi.io.storage.HoodieHFileReader | ||
| import org.apache.spark.execution.datasources.HoodieInMemoryFileIndex | ||
| import org.apache.spark.internal.Logging | ||
|
|
@@ -49,9 +50,9 @@ import org.apache.spark.sql.sources.{BaseRelation, Filter, PrunedFilteredScan} | |
| import org.apache.spark.sql.types.{StringType, StructField, StructType} | ||
| import org.apache.spark.sql.{Row, SQLContext, SparkSession} | ||
| import org.apache.spark.unsafe.types.UTF8String | ||
|
|
||
| import java.net.URI | ||
| import java.util.Locale | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.util.control.NonFatal | ||
| import scala.util.{Failure, Success, Try} | ||
|
|
@@ -509,12 +510,21 @@ abstract class HoodieBaseRelation(val sqlContext: SQLContext, | |
| StructType(dataStructSchema.filterNot(f => partitionColumns.contains(f.name))) | ||
|
|
||
| private def isSchemaEvolutionEnabled = { | ||
| // Auto set schema evolution | ||
| def detectSchemaEvolution(): Boolean = { | ||
|
Contributor
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. I see
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. I'm sorry we might not be able to do that, |
||
| val result = metaClient.isValidHistorySchemaExist | ||
| if (result) { | ||
| sparkSession.sessionState.conf.setConfString(DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.key, result.toString) | ||
|
Contributor
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. Why are we overriding configuration here? I don't think we should be overriding configs in such a way |
||
| } | ||
| result | ||
| } | ||
| // NOTE: Schema evolution could be configured both t/h optional parameters vehicle as well as | ||
| // t/h Spark Session configuration (for ex, for Spark SQL) | ||
| optParams.getOrElse(DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.key, | ||
| DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.defaultValue.toString).toBoolean || | ||
| sparkSession.conf.get(DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.key, | ||
| DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.defaultValue.toString).toBoolean | ||
| DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED.defaultValue.toString).toBoolean || | ||
| detectSchemaEvolution() | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
What's history-schema?