jtuglu1 commented on code in PR #18515:
URL: https://github.com/apache/druid/pull/18515#discussion_r2363536890
##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -1206,4 +1274,27 @@ public static boolean isStatementException(Throwable e)
return e instanceof StatementException ||
(e instanceof CallbackFailedException && e.getCause() instanceof
StatementException);
}
+
+ /**
+ * Used to ensure full index coverage in the presence of large index names.
+ * Returned indentifiers are of the format: `idx_{tableName}_{SHA of column
list}`.
+ *
+ * @param tableName the table name
+ * @param columns the set of columns to create the index on
(case-insensitive)
+ * @return unique index identifier
+ */
+ @VisibleForTesting
+ protected String generateSHABasedIndexIdentifier(String tableName,
List<String> columns)
+ {
+ final String prefix = "idx_" + tableName + "_";
+ final String columnDigest = DigestUtils.sha1Hex(
+ columns.stream()
+ .map(StringUtils::toLowerCase)
+ .collect(Collectors.joining("_"))
+ );
+ return prefix + columnDigest.substring(
Review Comment:
> We should include the table name in generating the digest
Sure.
> rather than truncating the digest, we should truncate the table name
itself.
Hmm, that doesn't sound great. I'd prefer to always have the table name. I'm
optimizing for avoiding collisions with names within same cluster/table as well
as tables between clusters. The SHA was supposed to introduce enough entropy
where suffixes didn't overlap (I think the likelihood of this is extremely low
as it is currently, even lower than chance of colliding on table name if we
were to truncate the table name). I'd suggest leaving for now.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]