jiangxt2 commented on code in PR #12274:
URL: https://github.com/apache/gravitino/pull/12274#discussion_r3793542983
##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java:
##########
@@ -1642,6 +1661,43 @@ private String buildDataSkippingIndexDdl(
.formatted(quoteIdentifier(indexName), fieldStr, typeName,
granularity);
}
+ /**
+ * Extracts engine parameters from the {@code engine_full} column of {@code
system.tables}.
+ *
+ * <p>Uses bracket-depth counting to correctly handle nested parentheses
(e.g. {@code
+ * SummingMergeTree((a, b))} returns {@code "(a, b)"}). For {@code
ReplacingMergeTree(ts)},
+ * returns {@code "ts"}. For engines without parameters (e.g. {@code
MergeTree}), returns {@code
+ * null}.
+ */
+ @VisibleForTesting
+ static String extractEngineParams(String engineName, String engineFull) {
+ if (StringUtils.isBlank(engineFull) || StringUtils.isBlank(engineName)) {
+ return null;
+ }
+ if (!StringUtils.startsWithIgnoreCase(engineFull, engineName)) {
+ return null;
+ }
+ int paramsStart = engineName.length();
+ if (paramsStart >= engineFull.length() || engineFull.charAt(paramsStart)
!= '(') {
+ return null;
+ }
+ // Bracket-depth counting handles nested parentheses (e.g.
SummingMergeTree((a, b))).
+ int depth = 0;
+ for (int i = paramsStart + 1; i < engineFull.length(); i++) {
+ char ch = engineFull.charAt(i);
+ if (ch == '(') {
+ depth++;
+ } else if (ch == ')') {
Review Comment:
Fixed in 7517295a. The scanner now handles quoted strings, quoted
identifiers, escapes, and nested parentheses correctly, with corresponding
regression tests.
--
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]