jiangxt2 commented on code in PR #11806:
URL: https://github.com/apache/gravitino/pull/11806#discussion_r3544505937


##########
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:
   Thanks for the suggestion! I looked into NumberUtils.isCreatable — it 
accepts hex (0xFF), decimals (3.14), scientific notation (1.2e3), and negative 
numbers, which are all invalid for granularity (must be a positive integer ≥ 
1). So I think the current Long.parseLong + range check is more appropriate 
here.



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

Reply via email to