KurtYoung commented on a change in pull request #10394: 
[FLINK-14663]Distinguish catalogColumnStats' unknown  value and real values
URL: https://github.com/apache/flink/pull/10394#discussion_r353638553
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV120.java
 ##########
 @@ -162,15 +174,23 @@ public CatalogColumnStatisticsDataDate 
toFlinkDateColStats(ColumnStatisticsData
                try {
                        Object dateStats = 
ColumnStatisticsData.class.getDeclaredMethod("getDateStats").invoke(hiveDateColStats);
                        Class dateStatsClz = dateStats.getClass();
-                       long numDV = (long) 
dateStatsClz.getMethod("getNumDVs").invoke(dateStats);
-                       long numNull = (long) 
dateStatsClz.getMethod("getNumNulls").invoke(dateStats);
+                       boolean isSetNumDv = (boolean) 
dateStatsClz.getMethod("isSetNumDVs").invoke(dateStats);
+                       boolean isSetNumNull = (boolean) 
dateStatsClz.getMethod("isSetNumNulls").invoke(dateStats);
+                       boolean isSetHighValue = (boolean) 
dateStatsClz.getMethod("isSetHighValue").invoke(dateStats);
+                       boolean isSetLowValue = (boolean) 
dateStatsClz.getMethod("isSetLowValue").invoke(dateStats);
+                       Long numDV = isSetNumDv ? (Long) 
dateStatsClz.getMethod("getNumDVs").invoke(dateStats) : null;
+                       Long numNull = isSetNumNull ? (Long) 
dateStatsClz.getMethod("getNumNulls").invoke(dateStats) : null;
                        Object hmsHighDate = 
dateStatsClz.getMethod("getHighValue").invoke(dateStats);
                        Object hmsLowDate = 
dateStatsClz.getMethod("getLowValue").invoke(dateStats);
                        Class hmsDateClz = hmsHighDate.getClass();
                        Method hmsDateDays = 
hmsDateClz.getMethod("getDaysSinceEpoch");
-                       long highDateDays = (long) 
hmsDateDays.invoke(hmsHighDate);
-                       long lowDateDays = (long) 
hmsDateDays.invoke(hmsLowDate);
-                       return new CatalogColumnStatisticsDataDate(new 
Date(lowDateDays), new Date(highDateDays), numDV, numNull);
+                       Long highDateDays = isSetHighValue ? (Long) 
hmsDateDays.invoke(hmsHighDate) : null;
+                       Long lowDateDays = isSetLowValue ? (Long) 
hmsDateDays.invoke(hmsLowDate) : null;
+                       return new CatalogColumnStatisticsDataDate(
+                                       isSetLowValue ? new Date(lowDateDays) : 
null,
 
 Review comment:
   Could you group the logical related to `isSetLowValue` or `isSetHighValue` 
together? Currently this flag is used in different places but with the same 
purpose. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to