bowenli86 commented on a change in pull request #8965: [FLINK-13068][hive] 
HiveTableSink should implement PartitionableTable…
URL: https://github.com/apache/flink/pull/8965#discussion_r300099032
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/batch/connectors/hive/HiveTableSink.java
 ##########
 @@ -161,4 +164,37 @@ private String toStagingDir(String finalDir, 
Configuration conf) throws IOExcept
                fs.deleteOnExit(path);
                return res;
        }
+
+       @Override
+       public List<String> getPartitionFieldNames() {
+               return catalogTable.getPartitionKeys();
+       }
+
+       @Override
+       public void setStaticPartition(Map<String, String> partitions) {
+               // make it a LinkedHashMap to maintain partition column order
+               staticPartitionSpec = new LinkedHashMap<>();
+               for (String partitionCol : getPartitionFieldNames()) {
+                       if (partitions.containsKey(partitionCol)) {
+                               staticPartitionSpec.put(partitionCol, 
partitions.get(partitionCol));
+                       }
+               }
+       }
+
+       private void validatePartitionSpec() {
+               List<String> partitionCols = getPartitionFieldNames();
+               Preconditions.checkArgument(new 
HashSet<>(partitionCols).containsAll(
 
 Review comment:
   A few comments here:
   
   - can we output which column is unknown to the error message?
   - the check of `new 
HashSet<>(partitionCols).containsAll(staticPartitionSpec.keySet())` will lose 
order of the partitions, which seems to be not enough for a legit validation. 
Shall it be `partitionCols.equals(new 
ArrayList(staticPartitionSpec.keySet()))`? since staticPartitionSpec is a 
linked hashmap, keys from its `keySet()` should be ordered
   
   - nit: can we reformat it to be more readable?
   
   ```
   Preconditions.checkArgument(
       ...
       "...";
   ```

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