yuqi1129 commented on code in PR #11806:
URL: https://github.com/apache/gravitino/pull/11806#discussion_r3544325402
##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java:
##########
@@ -504,6 +519,56 @@ private void appendIndexesSql(Index[] indexes,
StringBuilder sqlBuilder) {
}
}
+ /**
+ * Resolves the GRANULARITY value for a data skipping index from its
properties, falling back to
+ * the ClickHouse default. The value is interpolated directly into DDL, so
it must be a positive
+ * integer (≥ 1) to avoid generating malformed SQL.
+ *
+ * @param index the index whose {@code granularity} property is read
+ * @return the validated GRANULARITY value as a string
+ * @throws IllegalArgumentException if the value is not a positive integer
+ */
+ private static String resolveGranularity(Index index) {
+ String granularity =
+ index.properties().getOrDefault(INDEX_GRANULARITY_KEY,
DEFAULT_INDEX_GRANULARITY);
+ Preconditions.checkArgument(
+ granularity != null && !granularity.isBlank(),
+ "Index %s granularity must not be null or blank",
+ index.name());
+ try {
+ long value = Long.parseLong(granularity);
+ Preconditions.checkArgument(
Review Comment:
Can you try to use `NumberUtils.isCreatable` to simplify the code?
--
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]