jtuglu1 commented on code in PR #18515:
URL: https://github.com/apache/druid/pull/18515#discussion_r2377897537
##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -1206,4 +1276,27 @@ public static boolean isStatementException(Throwable e)
return e instanceof StatementException ||
(e instanceof CallbackFailedException && e.getCause() instanceof
StatementException);
}
+
+ /**
+ * Creates a unique index name of the format {@code idx_<tableName>_<SHA of
table name + column list>}
+ * with an SHA length of {@value MAX_INDEX_HASH_LENGTH}.
+ *
+ * @param tableName the table name
+ * @param columns the set of columns to create the index on
(case-insensitive)
+ * @return unique index identifier
+ */
+ protected String generateUniqueIndexName(String tableName, List<String>
columns)
+ {
+ final String prefix = "idx_" + tableName + "_";
+ final String tableAndColumnDigest = DigestUtils.sha1Hex(
+ StringUtils.format(
+ "%s_%s",
+ tableName,
Review Comment:
> I recall I had advised adding the table name in the generation of the
digest. But now since we are already prefixing the table name, we may omit this.
We aren't prefixing table name. SHA is the only thing being cut to 10 chars
(down from 20 chars). Again, this is still best effort after a certain length
of `idx_<table>`. In the worst case, for `datasource_upgraded_from_segment_id`,
it's saving 25 characters of space.
If this is still too long for the engine, we throw an exception, log it, and
silently continue. I feel like 10 chars is even generous (we could probably do
5 bytes of entropy and be fine).
--
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]