danny0405 commented on code in PR #12225:
URL: https://github.com/apache/hudi/pull/12225#discussion_r1835870363
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HoodieHiveCatalog.java:
##########
@@ -978,6 +983,34 @@ private Map<String, String> supplementOptions(
}
}
+ public void validateParameter(CatalogBaseTable table) {
+ Map<String, String> properties = new HashMap<>(table.getOptions());
+
+ //check pk
+ if (table.getUnresolvedSchema().getPrimaryKey().isPresent()
+ && properties.containsKey(FlinkOptions.RECORD_KEY_FIELD.key())) {
+ List<String> pks =
table.getUnresolvedSchema().getPrimaryKey().get().getColumnNames();
+ String[] primaryKeyFromParameter =
properties.get(FlinkOptions.RECORD_KEY_FIELD.key()).split(",");
+ for (String field : primaryKeyFromParameter) {
+ if (!pks.contains(field)) {
+ throw new HoodieValidationException("Failed to create table, please
check primary key statement and parameter " +
FlinkOptions.RECORD_KEY_FIELD.key());
+ }
+ }
+ }
+
+ //check partition key
+ CatalogTable catalogTable = (CatalogTable) table;
+ if (catalogTable.isPartitioned() &&
properties.containsKey(FlinkOptions.PARTITION_PATH_FIELD.key())) {
+ final List<String> partitions = catalogTable.getPartitionKeys();
+ final String[] partitionsFromParameter =
properties.get(FlinkOptions.PARTITION_PATH_FIELD.key()).split(",");
+ for (String field : partitionsFromParameter) {
+ if (!partitions.contains(field)) {
+ throw new HoodieValidationException("Failed to create table, please
check partition key statement and parameter " +
FlinkOptions.PARTITION_PATH_FIELD.key());
Review Comment:
Similiar suggestion.
--
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]