Interface INamespace

All Known Implementing Classes:
AbstractNamespace, CTENamespace, DynamicStarSource, OraclePackageNamespace, PivotNamespace, PlsqlVariableNamespace, SubqueryNamespace, TableNamespace, UnionNamespace, UnnestNamespace, ValuesNamespace

public interface INamespace
Represents a namespace that exposes columns. A namespace can be a table, subquery, CTE, etc. Key responsibilities: 1. Provide column existence checks (hasColumn) 2. Resolve column names to ColumnSource 3. Support SELECT * expansion 4. Track data lineage (getFinalTable) Design based on Apache Calcite's SqlValidatorNamespace
  • Method Details

    • getDisplayName

      Get a display name for this namespace (for debugging/error messages)
    • hasColumn

      Check if a column exists in this namespace. Returns a three-level answer: EXISTS, MAYBE, NOT_EXISTS
      Parameters:
      columnName - Column name to check
      Returns:
      Column existence level
    • resolveColumn

      Resolve a column name to its source.
      Parameters:
      columnName - Column name to resolve
      Returns:
      ColumnSource if found, null otherwise
    • resolveColumnPath

      Resolve a column path (column.field.subfield...) to its source.

      This method supports deep/record field access patterns like customer.address.city where:

      • path[0] is the base column name (e.g., "customer")
      • path[1..n] are field paths (e.g., ["address", "city"])
      Parameters:
      path - The column path segments
      Returns:
      ColumnSource with fieldPath set, or null if base column not found
    • getAllColumnSources

      Get all column sources exposed by this namespace. Used for SELECT * expansion and smart completion.
      Returns:
      Map of column name -> ColumnSource
    • getFinalTable

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

      Get all final physical tables this namespace depends on. For simple table namespace: returns single table For subquery/CTE: returns all tables in the query tree
      Returns:
      List of all physical tables
    • isValidated

      boolean isValidated()
      Check if this namespace is validated/resolved. Some namespaces require resolution before they can provide column info.
      Returns:
      true if validated
    • validate

      void validate()
      Validate/resolve this namespace. For subqueries: resolve the SELECT list For tables: load metadata if needed
    • getNode

      Get the associated AST node (TTable, TSelectSqlStatement, etc.)
      Returns:
      AST node, or null if not applicable
    • getSelectStatement

      Get the underlying SELECT statement for this namespace. For CTENamespace: returns the CTE's subquery For SubqueryNamespace: returns the subquery For TableNamespace: returns null
      Returns:
      the SELECT statement, or null if not applicable
    • hasStarColumn

      default boolean hasStarColumn()
      Check if this namespace contains a star column (SELECT *). Used to identify namespaces that may need star column inference.
      Returns:
      true if the namespace has SELECT *, false otherwise
    • addInferredColumn

      default boolean addInferredColumn(String columnName, double confidence, String evidence)
      Add an inferred column to this namespace. Used by star column push-down to add columns discovered from outer queries.
      Parameters:
      columnName - the column name to add
      confidence - the confidence score (0.0 to 1.0)
      evidence - description of why this column was inferred
      Returns:
      true if the column was added, false if already exists
    • getInferredColumns

      Get all columns that were inferred (not from SELECT list directly). These are columns discovered through star column push-down.
      Returns:
      set of inferred column names, empty if none
    • supportsDynamicInference

      default boolean supportsDynamicInference()
      Check if this namespace supports dynamic column inference. DynamicStarSource and similar namespaces return true.
      Returns:
      true if this namespace can have columns added dynamically
    • getStarColumn

      Get the star column (SELECT *) from this namespace if one exists. Used to track the sourceColumn for columns inferred from a star.
      Returns:
      The star column TResultColumn, or null if no star column exists
    • getSourceTable

      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