xuefuz commented on a change in pull request #10381: [FLINK-14513][hive] 
Implement listPartitionsByFilter to HiveCatalog
URL: https://github.com/apache/flink/pull/10381#discussion_r355642780
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/HiveTableSource.java
 ##########
 @@ -195,41 +189,28 @@ public boolean isLimitPushedDown() {
 
        @Override
        public TableSource<BaseRow> applyLimit(long limit) {
-               return new HiveTableSource(jobConf, tablePath, catalogTable, 
allHivePartitions, hiveVersion,
-                                               partitionList, 
initAllPartitions, partitionPruned, projectedFields, true, limit);
+               return new HiveTableSource(jobConf, tablePath, catalogTable, 
remainingPartitions, hiveVersion,
+                                               partitionPruned, 
projectedFields, true, limit);
        }
 
        @Override
        public List<Map<String, String>> getPartitions() {
-               if (!initAllPartitions) {
-                       initAllPartitions();
-               }
-               return partitionList;
+               throw new RuntimeException("This method is not expected to be 
called. " +
+                               "Please use Catalog API to retrieve all 
partitions of a table");
        }
 
        @Override
        public TableSource<BaseRow> applyPartitionPruning(List<Map<String, 
String>> remainingPartitions) {
                if (catalogTable.getPartitionKeys() == null || 
catalogTable.getPartitionKeys().size() == 0) {
                        return this;
                } else {
-                       if (!initAllPartitions) {
-                               initAllPartitions();
-                       }
-
-                       List<HiveTablePartition> remainingHivePartitions = new 
ArrayList<>();
-                       for (Map<String, String> partitionSpec : 
remainingPartitions) {
-                               HiveTablePartition hiveTablePartition = 
partitionSpec2HiveTablePartition.get(partitionSpec);
-                               Preconditions.checkNotNull(hiveTablePartition, 
String.format("remainingPartitions must contain " +
-                                                                               
                                                                        
"partition spec %s", partitionSpec));
-                               remainingHivePartitions.add(hiveTablePartition);
-                       }
-                       return new HiveTableSource(jobConf, tablePath, 
catalogTable, remainingHivePartitions, hiveVersion,
-                                               partitionList, true, true, 
projectedFields, isLimitPushDown, limit);
+                       return new HiveTableSource(jobConf, tablePath, 
catalogTable, remainingPartitions, hiveVersion,
+                                       true, projectedFields, isLimitPushDown, 
limit);
                }
        }
 
-       private void initAllPartitions() {
-               allHivePartitions = new ArrayList<>();
+       private List<HiveTablePartition> initAllPartitions() {
 
 Review comment:
   Nit: we might rename the method to better reflect what's actually doing.

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