lirui-apache commented on a change in pull request #8614: [FLINK-12727][hive] 
Make HiveTableOutputFormat support writing partitioned table
URL: https://github.com/apache/flink/pull/8614#discussion_r292725211
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/batch/connectors/hive/HiveTableOutputFormat.java
 ##########
 @@ -319,26 +328,25 @@ public void writeRecord(Row record) throws IOException {
        }
 
        // load a single partition
-       private void loadPartition(Path srcDir, Table table, Map<String, 
String> partSpec, HiveMetastoreClientWrapper client)
-                       throws TException, IOException {
+       private void loadPartition(Path srcDir, Table table, Map<String, 
String> partSpec, HiveCatalog catalog)
+                       throws IOException, TableNotPartitionedException, 
TableNotExistException, PartitionNotExistException,
+                       PartitionAlreadyExistsException, 
PartitionSpecInvalidException, MetaException {
                Path tblLocation = new Path(table.getSd().getLocation());
-               List<Partition> existingPart = 
client.listPartitions(databaseName, tableName,
-                               new ArrayList<>(partSpec.values()), (short) 1);
-               Path destDir = existingPart.isEmpty() ? new Path(tblLocation, 
Warehouse.makePartPath(partSpec)) :
-                               new 
Path(existingPart.get(0).getSd().getLocation());
+               ObjectPath tablePath = new ObjectPath(databaseName, tableName);
+               CatalogPartitionSpec catalogPartitionSpec = new 
CatalogPartitionSpec(partSpec);
+               List<CatalogPartitionSpec> existingPart = 
catalog.listPartitions(tablePath, catalogPartitionSpec);
 
 Review comment:
   We can't if we don't use a catalog. But I guess it's fine because we won't 
list all partitions, but only partitions matching the provided spec.

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