xuefuz commented on a change in pull request #6906: [Flink-6036][table]Let catalog support partition. URL: https://github.com/apache/flink/pull/6906#discussion_r227924642
########## File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/catalog/InMemoryExternalCatalog.scala ########## @@ -120,4 +122,122 @@ class InMemoryExternalCatalog(name: String) extends CrudExternalCatalog { override def listSubCatalogs(): JList[String] = synchronized { databases.keys.toList.asJava } + + /** + * Adds partition into an external Catalog table + * + * @param tableName table name + * @param partition partition description of partition which to create + * @param ignoreIfExists if partition already exists in the catalog, not throw exception and + * leave the existed partition if ignoreIfExists is true; + * else throw PartitionAlreadyExistException + * @throws TableNotExistException if table does not exist in the catalog yet + * @throws PartitionAlreadyExistException if partition exists in the catalog and + * ignoreIfExists is false + */ + override def createPartition( + tableName: String, + partition: ExternalCatalogPartition, + ignoreIfExists: Boolean): Unit = synchronized { + val newPartSpec = partition.partitionSpec + val table = getTable(tableName) + val partitions = getPartitions(tableName, table) + if (partitions.contains(newPartSpec)) { + if (!ignoreIfExists) { + throw new PartitionAlreadyExistException(name, tableName, newPartSpec) + } + } else { + partitions.put(newPartSpec, partition) Review comment: We might want to validate if the partitionSpec is what the table is expecting. Otherwise, we might insert some partition who's partition columns are different from how the table is partitioned. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services