
Answer-first summary for fast verification
Answer: TRUNC(ID_NUMBER, -6)
Snowflake recommends reducing the cardinality of high-cardinality columns when defining clustering keys to improve clustering effectiveness. The TRUNC(ID_NUMBER, -6) function truncates the last 6 digits to zeros, effectively grouping similar ID ranges together while significantly reducing cardinality. This approach is optimal because: 1) It maintains data locality by grouping sequential IDs, 2) It dramatically reduces the number of distinct values in the clustering key, and 3) It aligns with Snowflake's documentation on using TRUNC with negative scale values for this purpose. Option B (TRUNC(ID_NUMBER, 5)) would truncate to 5 decimal places, which is irrelevant for integer IDs. Option C (ID_NUMBER*100) would increase cardinality, making clustering worse. Option D (TO_CHAR(ID_NUMBER)) converts to string but maintains full cardinality, providing no clustering benefit.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
What is Snowflake's recommended approach for defining a clustering key on a table with a high-cardinality column, such as an ID_NUMBER column containing 15-digit numeric identifiers?
A
TRUNC(ID_NUMBER, -6)
B
TRUNC(ID_NUMBER, 5)
C
ID_NUMBER*100
D
TO_CHAR(ID_NUMBER)
No comments yet.