Class TableNamespace

Object
gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
gudusoft.gsqlparser.resolver2.namespace.TableNamespace
All Implemented Interfaces:
INamespace

public class TableNamespace extends AbstractNamespace
Namespace representing a physical table. Provides column information from table metadata. Column sources come from: 1. Table metadata (if available from DDL) 2. External metadata providers (SQLEnv) 3. Inferred from usage (when no metadata available)
  • Constructor Details

  • Method Details

    • setSqlEnv

      public void setSqlEnv(TSQLEnv sqlEnv)
      Set the TSQLEnv for metadata lookup.
      Parameters:
      sqlEnv - the SQL environment containing table metadata
    • getSqlEnv

      public TSQLEnv getSqlEnv()
      Get the TSQLEnv used for metadata lookup.
      Returns:
      the SQL environment, or null if not set
    • setVendor

      public void setVendor(EDbVendor vendor)
      Set the database vendor.
      Parameters:
      vendor - the database vendor
    • getVendor

      public EDbVendor getVendor()
      Get the database vendor.
      Returns:
      the database vendor, or null if not set
    • getQualifiedNameResolver

      Get the qualified name resolver.
      Returns:
      the resolver, or null if sqlEnv is not set
    • getQualifiedName

      Get the fully qualified name of this table.

      The qualified name is computed by applying defaults from TSQLEnv to the table's partial name.

      Returns:
      the qualified name, or null if table name is unavailable
    • getResolvedTable

      Get the resolved TSQLTable from SQLEnv.
      Returns:
      the resolved table, or null if not found in SQLEnv
    • getDisplayName

      Description copied from interface: INamespace
      Get a display name for this namespace (for debugging/error messages)
    • getFinalTable

      Description copied from interface: INamespace
      Get the final physical table this namespace represents. For tables: returns the table itself For subqueries/CTEs: recursively traces back to physical table(s)
      Returns:
      Physical table, or null if not determinable
    • getSourceTable

      Description copied from interface: INamespace
      Get the TTable that this namespace is associated with. Used for legacy sync to set TObjectName.sourceTable. For TableNamespace: returns the table itself For SubqueryNamespace: returns the TTable wrapping the subquery For CTENamespace: returns the CTE referencing table For others: returns null
      Returns:
      The source TTable, or null if not applicable
    • doValidate

      protected void doValidate()
      Description copied from class: AbstractNamespace
      Subclasses override this to perform actual validation logic.
      Specified by:
      doValidate in class AbstractNamespace
    • hasColumn

      public ColumnLevel hasColumn(String columnName)
      Description copied from interface: INamespace
      Check if a column exists in this namespace. Returns a three-level answer: EXISTS, MAYBE, NOT_EXISTS
      Specified by:
      hasColumn in interface INamespace
      Overrides:
      hasColumn in class AbstractNamespace
      Parameters:
      columnName - Column name to check
      Returns:
      Column existence level
    • resolveColumn

      public ColumnSource resolveColumn(String columnName)
      Description copied from interface: INamespace
      Resolve a column name to its source.
      Specified by:
      resolveColumn in interface INamespace
      Overrides:
      resolveColumn in class AbstractNamespace
      Parameters:
      columnName - Column name to resolve
      Returns:
      ColumnSource if found, null otherwise
    • getTable

      public TTable getTable()
    • hasMetadata

      public boolean hasMetadata()
      Returns true if this namespace has actual metadata (from DDL or SQLEnv). When false, column resolution will infer columns from usage.
      Returns:
      true if metadata is available, false if columns are inferred
    • addUsingColumn

      public void addUsingColumn(String columnName)
      Add a USING clause column to this table's namespace. This is called during scope building when a JOIN...USING clause includes columns from this table. The USING column exists in BOTH tables of the join.
      Parameters:
      columnName - the name of the USING column
    • toString

      public String toString()
      Overrides:
      toString in class AbstractNamespace