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


##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java:
##########
@@ -2310,11 +2353,113 @@ private static boolean 
isParameterizedBloomFilterIndex(Index.IndexType indexType
         || indexType == Index.IndexType.DATA_SKIPPING_TOKENBFV1;
   }
 
+  private static Map<String, String> parseLegacyAnnUsearchProperties(
+      Index.IndexType indexType, String typeFull, String indexName) {
+    String expectedType = legacyAnnUsearchTypeName(indexType);
+    String rawTypeFull = StringUtils.defaultString(typeFull);
+    String normalizedTypeFull = rawTypeFull.trim();
+    Map<String, String> properties = new HashMap<>();
+    if (StringUtils.isNotEmpty(rawTypeFull)) {
+      properties.put(CLICKHOUSE_TYPE_FULL, rawTypeFull);
+    }
+
+    int paramsStart = normalizedTypeFull.indexOf('(');
+    int paramsEnd = normalizedTypeFull.lastIndexOf(')');
+    if (paramsStart < 0 && StringUtils.equalsIgnoreCase(expectedType, 
normalizedTypeFull)) {
+      LOG.warn(
+          "ClickHouse metadata does not expose legacy {} parameters for index 
'{}'; "
+              + "preserving the reported type expression only",
+          expectedType,
+          indexName);
+      return Map.copyOf(properties);
+    }
+    if (paramsStart <= 0
+        || paramsEnd != normalizedTypeFull.length() - 1
+        || !StringUtils.equalsIgnoreCase(
+            expectedType, normalizedTypeFull.substring(0, 
paramsStart).trim())) {
+      LOG.warn(
+          "Could not parse legacy ClickHouse type expression '{}' for index 
'{}' of type {}; "
+              + "preserving it in '{}'",
+          rawTypeFull,
+          indexName,
+          expectedType,
+          CLICKHOUSE_TYPE_FULL);
+      return Map.copyOf(properties);
+    }
+
+    String[] parameters = normalizedTypeFull.substring(paramsStart + 1, 
paramsEnd).split(",", -1);
+    if (parameters.length != 1 || StringUtils.isBlank(parameters[0])) {

Review Comment:
   Fixed in 395f2d9. Empty-parameter Annoy definitions such as `annoy()` are 
now treated as valid. The original `clickhouse_type_full` and granularity are 
preserved without a parsing warning. The parser unit test and live Annoy 
integration test passed.



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