You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/03/08 23:55:04 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6658: Add context on data type transform failure

Jackie-Jiang commented on a change in pull request #6658:
URL: https://github.com/apache/incubator-pinot/pull/6658#discussion_r589836707



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/data/recordtransformer/DataTypeTransformer.java
##########
@@ -80,39 +80,43 @@ public DataTypeTransformer(Schema schema) {
   public GenericRow transform(GenericRow record) {
     for (Map.Entry<String, PinotDataType> entry : _dataTypes.entrySet()) {
       String column = entry.getKey();
-      Object value = record.getValue(column);
-      if (value == null) {
-        continue;
-      }
-      PinotDataType dest = entry.getValue();
-      value = standardize(column, value, dest.isSingleValue());
-      // NOTE: The standardized value could be null for empty Collection/Map/Object[].
-      if (value == null) {
-        record.putValue(column, null);
-        continue;
-      }
+      try {
+        Object value = record.getValue(column);
+        if (value == null) {
+          continue;
+        }
+        PinotDataType dest = entry.getValue();
+        value = standardize(column, value, dest.isSingleValue());
+        // NOTE: The standardized value could be null for empty Collection/Map/Object[].
+        if (value == null) {
+          record.putValue(column, null);
+          continue;
+        }
 
-      // Convert data type if necessary
-      PinotDataType source;
-      if (value instanceof Object[]) {
-        // Multi-value column
-        Object[] values = (Object[]) value;
-        source = MULTI_VALUE_TYPE_MAP.get(values[0].getClass());
-        if (source == null) {
-          source = PinotDataType.OBJECT_ARRAY;
+        // Convert data type if necessary
+        PinotDataType source;
+        if (value instanceof Object[]) {
+          // Multi-value column
+          Object[] values = (Object[]) value;
+          source = MULTI_VALUE_TYPE_MAP.get(values[0].getClass());
+          if (source == null) {
+            source = PinotDataType.OBJECT_ARRAY;
+          }
+        } else {
+          // Single-value column
+          source = SINGLE_VALUE_TYPE_MAP.get(value.getClass());
+          if (source == null) {
+            source = PinotDataType.OBJECT;
+          }
         }
-      } else {
-        // Single-value column
-        source = SINGLE_VALUE_TYPE_MAP.get(value.getClass());
-        if (source == null) {
-          source = PinotDataType.OBJECT;
+        if (source != dest) {
+          value = dest.convert(value, source);
         }
-      }
-      if (source != dest) {
-        value = dest.convert(value, source);
-      }
 
-      record.putValue(column, value);
+        record.putValue(column, value);
+      } catch (Exception e) {
+        throw new RuntimeException("failed to transform column " + column, e);

Review comment:
       ```suggestion
           throw new RuntimeException("Caught exception while transforming data type for column: " + column, e);
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org