danny0405 commented on code in PR #11914:
URL: https://github.com/apache/hudi/pull/11914#discussion_r1749394265


##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/SchemaEvolutionContext.java:
##########
@@ -98,21 +101,52 @@ public SchemaEvolutionContext(InputSplit split, JobConf 
job) throws IOException
   public SchemaEvolutionContext(InputSplit split, JobConf job, 
Option<HoodieTableMetaClient> metaClientOption) throws IOException {
     this.split = split;
     this.job = job;
-    this.metaClient = metaClientOption.isPresent() ? metaClientOption.get() : 
setUpHoodieTableMetaClient();
-    if (this.metaClient == null) {
+    if (!job.getBoolean(HIVE_EVOLUTION_ENABLE, true)) {
+      LOG.info("schema evolution is disabled for split: {}", split);
       internalSchemaOption = Option.empty();
+      this.metaClient = null;
       return;
     }
-    try {
-      TableSchemaResolver schemaUtil = new TableSchemaResolver(metaClient);
-      this.internalSchemaOption = 
schemaUtil.getTableInternalSchemaFromCommitMetadata();
-    } catch (Exception e) {
-      internalSchemaOption = Option.empty();
-      LOG.warn(String.format("failed to get internal Schema from hudi 
table:%s", metaClient.getBasePath()), e);
+    this.metaClient = metaClientOption.isPresent() ? metaClientOption.get() : 
setUpHoodieTableMetaClient();
+    if (job.getBoolean(INTERNAL_SCHEMA_CACHE_VISIT, false)) {
+      Option<StoragePath> tablePath = getTablePath(job, split);
+      if (metaClient != null && tablePath.isPresent()) {
+        String schemaJson = job.get(INTERNAL_SCHEMA_CACHE_PREFIX + "." + 
tablePath.get().toUri(), "");
+        this.internalSchemaOption = SerDeHelper.fromJson(schemaJson);
+        if (internalSchemaOption.isPresent()) {
+          LOG.info("get internal schema from conf for split: {}" + split);
+        }
+      } else {
+        try {
+          TableSchemaResolver schemaUtil = new TableSchemaResolver(metaClient);
+          this.internalSchemaOption = 
schemaUtil.getTableInternalSchemaFromCommitMetadata();
+        } catch (Exception e) {
+          internalSchemaOption = Option.empty();
+          LOG.warn(String.format("failed to get internal Schema from hudi 
table:%s", metaClient.getBasePath()), e);
+        }
+      }
+    } else {
+      try {
+        TableSchemaResolver schemaUtil = new TableSchemaResolver(metaClient);

Review Comment:
   This is invalid code path because the table itself is invalid.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to