You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "jackxu2011 (via GitHub)" <gi...@apache.org> on 2023/02/22 07:27:32 UTC

[GitHub] [linkis] jackxu2011 commented on a diff in pull request #4255: [feat] support different hive version

jackxu2011 commented on code in PR #4255:
URL: https://github.com/apache/linkis/pull/4255#discussion_r1113925124


##########
linkis-engineconn-plugins/hive/src/main/java/org/apache/linkis/engineplugin/hive/serde/CustomerDelimitedJSONSerDe.java:
##########
@@ -329,7 +320,48 @@ private static void writePrimitiveUTF8(
         }
       default:
         {
-          throw new RuntimeException("Unknown primitive type: " + category);
+          boolean containsIntervalYearMonth = false;
+          boolean containsIntervalDayTime = false;
+          for (PrimitiveObjectInspector.PrimitiveCategory primitiveCategory :
+              PrimitiveObjectInspector.PrimitiveCategory.values()) {
+            containsIntervalYearMonth = "INTERVAL_YEAR_MONTH".equals(primitiveCategory.name());
+            containsIntervalDayTime = "INTERVAL_DAY_TIME".equals(primitiveCategory.name());
+            try {
+              if (containsIntervalYearMonth) {
+                wc =
+                    (WritableComparable)
+                        ClassUtils.getClassInstance(
+                                "org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalYearMonthObjectInspector")
+                            .getClass()
+                            .getMethod("getPrimitiveWritableObject", Object.class)
+                            .invoke(oi, o);
+                binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
+                break;
+              }
+              if (containsIntervalDayTime) {
+                wc =
+                    (WritableComparable)
+                        ClassUtils.getClassInstance(
+                                "org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalDayTimeObjectInspector")
+                            .getClass()
+                            .getMethod("getPrimitiveWritableObject", Object.class)
+                            .invoke(oi, o);
+                binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
+                break;
+              }
+            } catch (IllegalAccessException e) {
+              e.printStackTrace();

Review Comment:
   use log4j replace the printStackTrace



-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org