godfreyhe commented on code in PR #20084:
URL: https://github.com/apache/flink/pull/20084#discussion_r935538496


##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableSource.java:
##########
@@ -362,20 +367,29 @@ public TableStats reportStatistics() {
                 TableStats tableStats =
                         ((FileBasedStatisticsReportableInputFormat) 
bulkReaderFormat)
                                 .reportStatistics(files, producedDataType);
+                if (tableStats.equals(TableStats.UNKNOWN)) {
+                    return tableStats;
+                }
                 return limit == null
                         ? tableStats
                         : new TableStats(Math.min(limit, 
tableStats.getRowCount()));
             } else if (deserializationFormat instanceof 
FileBasedStatisticsReportableInputFormat) {
                 TableStats tableStats =
                         ((FileBasedStatisticsReportableInputFormat) 
deserializationFormat)
                                 .reportStatistics(files, producedDataType);
+                if (tableStats.equals(TableStats.UNKNOWN)) {
+                    return tableStats;
+                }
                 return limit == null
                         ? tableStats
                         : new TableStats(Math.min(limit, 
tableStats.getRowCount()));
             } else {
                 return TableStats.UNKNOWN;
             }
         } catch (Exception e) {
+            LOG.info(
+                    String.format(
+                            "Reporting statistics failed for file system table 
source: %s", e));

Review Comment:
    LOG.warn(Reporting statistics failed for file system table source: {}", 
e.getMessage());



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/connector/file/table/FileSystemStatisticsReportTest.java:
##########
@@ -287,4 +300,17 @@ public void 
testFilterPartitionPushDownAndReportStatisticsDisabled() {
                 getStatisticsFromOptimizedPlan("select * from PartTable where 
a > 10 and b = 1");
         assertThat(statistic.getTableStats()).isEqualTo(TableStats.UNKNOWN);
     }
+
+    @Test
+    public void testFileSystemSourceWithoutData() {
+        FlinkStatistic statistic = getStatisticsFromOptimizedPlan("select * 
from emptyTable");
+        assertThat(statistic.getTableStats()).isEqualTo(TableStats.UNKNOWN);
+    }
+
+    @Test
+    public void testFileSystemSourceWithoutDataWithLimitPushDown() {
+        FlinkStatistic statistic =

Review Comment:
   add TODO the update status in limit push rule when statistics is unknown



##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/HiveTableSource.java:
##########
@@ -336,6 +338,7 @@ public TableStats reportStatistics() {
             }
 
         } catch (Exception e) {
+            LOG.info(String.format("Reporting statistics failed for hive table 
source: %s", e));

Review Comment:
   ditto



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