public enum DisplayNamePolicy extends Enum<DisplayNamePolicy>
This policy determines "which occurrence to use" for deduplicated output
like Tables/Fields lists. It is separate from DisplayNameMode which
controls the visual rendering style.
SQL (Oracle): SELECT * FROM Emp; SELECT * FROM EMP; Both "Emp" and "EMP" refer to the same table (Oracle is case-insensitive for unquoted). When outputting the deduplicated Tables: list, which name do we use? PREFER_DEFINITION_SITE: Use the definition site spelling (if available) PREFER_FIRST_OCCURRENCE: Use "Emp" (first occurrence in SQL) PREFER_METADATA: Use whatever is stored in the database catalog
DisplayNameMode,
DisplayNameNormalizer| Enum Constant and Description |
|---|
PREFER_DEFINITION_SITE
Prefer the spelling from the definition site.
|
PREFER_FIRST_OCCURRENCE
Prefer the first occurrence in the SQL text.
|
PREFER_METADATA
Prefer the spelling from database metadata.
|
| Modifier and Type | Method and Description |
|---|---|
static DisplayNamePolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DisplayNamePolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DisplayNamePolicy PREFER_DEFINITION_SITE
This is the recommended default. It uses the name as written at the object's definition location:
WITH cte_name AS (...)FROM table AS aliasCREATE TABLE target AS ...If no definition site exists (e.g., external table reference), falls back to first occurrence.
public static final DisplayNamePolicy PREFER_FIRST_OCCURRENCE
Uses the spelling from the earliest position (by offset/line/column) in the source SQL. This provides deterministic output based purely on source order.
Example:
SELECT * FROM Emp WHERE emp.id = 1; -- First occurrence is "Emp", so output: Tables: Emp
public static final DisplayNamePolicy PREFER_METADATA
Uses the canonical name stored in the database catalog/metadata. Requires that the resolver has access to metadata (via SQLEnv) and that the object was successfully resolved to a catalog entry.
Useful when output should match the "official" database names, especially for databases where table names are case-sensitive (like BigQuery).
If metadata is unavailable, falls back to PREFER_DEFINITION_SITE.
public static DisplayNamePolicy[] values()
for (DisplayNamePolicy c : DisplayNamePolicy.values()) System.out.println(c);
public static DisplayNamePolicy valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is null