soumyakanti3578 commented on code in PR #6350:
URL: https://github.com/apache/hive/pull/6350#discussion_r2989591829


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -4271,14 +4271,25 @@ private List<FieldSchema> 
get_fields_with_environment_context_core(String db, St
       } catch (NoSuchObjectException e) {
         throw new UnknownTableException(e.getMessage());
       }
-      if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
+      String serdeLib = tbl.getSd().getSerdeInfo().getSerializationLib();
+      if (serdeLib == null ||
               MetastoreConf.getStringCollection(conf,
-                      ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
-                      tbl.getSd().getSerdeInfo().getSerializationLib())) {
+                      
ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(serdeLib)) {
         ret = tbl.getSd().getCols();
       } else {
-        StorageSchemaReader schemaReader = getStorageSchemaReader();
-        ret = schemaReader.readSchema(tbl, envContext, getConf());
+        try {
+          StorageSchemaReader schemaReader = getStorageSchemaReader();
+          ret = schemaReader.readSchema(tbl, envContext, getConf());
+        } catch (Exception e) {
+          if ("org.apache.hadoop.hive.serde2.avro.AvroSerDe".equals(serdeLib)) 
{
+            LOG.warn("Unable to read schema from storage for AvroSerDe table 
'{}.{}' ({}). " +
+                "Returning metastore SD columns as fallback; schema may be 
stale ",
+                db, tableName, e.getMessage());
+            ret = tbl.getSd().getCols();
+          } else {
+            throw new UnsupportedOperationException("Storage schema reading 
not supported");

Review Comment:
   I think here we should definitely include `e` in the new exception so as not 
to lose the stack.



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -4271,14 +4271,25 @@ private List<FieldSchema> 
get_fields_with_environment_context_core(String db, St
       } catch (NoSuchObjectException e) {
         throw new UnknownTableException(e.getMessage());
       }
-      if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
+      String serdeLib = tbl.getSd().getSerdeInfo().getSerializationLib();
+      if (serdeLib == null ||
               MetastoreConf.getStringCollection(conf,
-                      ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
-                      tbl.getSd().getSerdeInfo().getSerializationLib())) {
+                      
ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(serdeLib)) {
         ret = tbl.getSd().getCols();
       } else {
-        StorageSchemaReader schemaReader = getStorageSchemaReader();
-        ret = schemaReader.readSchema(tbl, envContext, getConf());
+        try {
+          StorageSchemaReader schemaReader = getStorageSchemaReader();
+          ret = schemaReader.readSchema(tbl, envContext, getConf());
+        } catch (Exception e) {
+          if ("org.apache.hadoop.hive.serde2.avro.AvroSerDe".equals(serdeLib)) 
{
+            LOG.warn("Unable to read schema from storage for AvroSerDe table 
'{}.{}' ({}). " +
+                "Returning metastore SD columns as fallback; schema may be 
stale ",
+                db, tableName, e.getMessage());

Review Comment:
   Is `e.getMessage()` enough here, or should we consider logging the whole 
exception? 



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -4271,14 +4271,25 @@ private List<FieldSchema> 
get_fields_with_environment_context_core(String db, St
       } catch (NoSuchObjectException e) {
         throw new UnknownTableException(e.getMessage());
       }
-      if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
+      String serdeLib = tbl.getSd().getSerdeInfo().getSerializationLib();
+      if (serdeLib == null ||
               MetastoreConf.getStringCollection(conf,
-                      ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
-                      tbl.getSd().getSerdeInfo().getSerializationLib())) {
+                      
ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(serdeLib)) {
         ret = tbl.getSd().getCols();
       } else {
-        StorageSchemaReader schemaReader = getStorageSchemaReader();
-        ret = schemaReader.readSchema(tbl, envContext, getConf());
+        try {
+          StorageSchemaReader schemaReader = getStorageSchemaReader();
+          ret = schemaReader.readSchema(tbl, envContext, getConf());
+        } catch (Exception e) {

Review Comment:
   Probably the scope of the exception can be narrowed here.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to