Enum DisplayNamePolicy

Object
Enum<DisplayNamePolicy>
gudusoft.gsqlparser.resolver2.format.DisplayNamePolicy
All Implemented Interfaces:
Serializable, Comparable<DisplayNamePolicy>, java.lang.constant.Constable

Policy for choosing the representative display name when the same object appears multiple times with different spellings (e.g., different case).

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.

Example:

 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
 
See Also:
  • Enum Constant Details

    • PREFER_DEFINITION_SITE

      Prefer the spelling from the definition site.

      This is the recommended default. It uses the name as written at the object's definition location:

      • CTE name: use the spelling in WITH cte_name AS (...)
      • Table alias: use the spelling in FROM table AS alias
      • CTAS target: use the spelling in CREATE TABLE target AS ...

      If no definition site exists (e.g., external table reference), falls back to first occurrence.

    • PREFER_FIRST_OCCURRENCE

      Prefer the first occurrence in the SQL text.

      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
       
    • PREFER_METADATA

      public static final DisplayNamePolicy PREFER_METADATA
      Prefer the spelling from database 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.

  • Method Details

    • values

      public static DisplayNamePolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static DisplayNamePolicy valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null