public class ColumnSource extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EVIDENCE_ALIAS_COLUMN_VIA_STAR
Evidence of a derived table's alias column name over a star whose expansion is not known (Mantis 4843):
the name is the derived table's column, and no column of the star's table is known to be behind it.
|
| Constructor and Description |
|---|
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode)
Constructor for definite matches (confidence = 1.0)
|
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
double confidence,
String evidence) |
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
double confidence,
String evidence,
TTable overrideTable) |
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
double confidence,
String evidence,
TTable overrideTable,
List<TTable> candidateTables) |
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
double confidence,
String evidence,
TTable overrideTable,
List<TTable> candidateTables,
ResolutionEvidence evidenceDetail)
Full constructor with all fields including ResolutionEvidence.
|
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
double confidence,
String evidence,
TTable overrideTable,
List<TTable> candidateTables,
ResolutionEvidence evidenceDetail,
FieldPath fieldPath)
Full constructor with all fields including ResolutionEvidence and FieldPath.
|
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
ResolutionEvidence evidenceDetail)
Constructor with ResolutionEvidence (preferred for new code).
|
ColumnSource(INamespace sourceNamespace,
String exposedName,
TParseTreeNode definitionNode,
ResolutionEvidence evidenceDetail,
TTable overrideTable)
Constructor with ResolutionEvidence and override table.
|
| Modifier and Type | Method and Description |
|---|---|
List<TTable> |
getAllFinalTables()
Get all physical tables that this column might originate from.
|
Map<TTable,Integer> |
getCandidateTableDdlStatus()
Get DDL verification status for all candidate tables.
|
List<TTable> |
getCandidateTables()
Get the candidate tables for ambiguous columns.
|
double |
getConfidence() |
static int |
getDdlVerificationStatus(TTable table,
String columnName)
Check DDL verification status for a candidate table.
|
SourceLocation |
getDefinitionLocation() |
TParseTreeNode |
getDefinitionNode() |
String |
getEvidence() |
ResolutionEvidence |
getEvidenceDetail()
Get the structured evidence detail for this resolution.
|
EvidenceType |
getEvidenceType()
Get the evidence type from the structured evidence detail.
|
String |
getExposedName() |
FieldPath |
getFieldPath()
Get the field path for deep/record field access.
|
String |
getFinalColumnName()
Get the original column name in the physical table when this column is an alias.
|
TTable |
getFinalTable()
Get the final physical table this column originates from after tracing
through all subqueries and CTEs.
|
TTable |
getOverrideTable()
Get the override table, if set.
|
INamespace |
getSourceNamespace() |
boolean |
hasDefiniteEvidence()
Check if this resolution has definite evidence (not inferred).
|
boolean |
hasFieldPath()
Check if this column source has a field path (deep/record field access).
|
static boolean |
hasTableDdl(TTable table)
Check if a table has DDL metadata available (from CREATE TABLE in same script).
|
boolean |
isAmbiguous()
Check if this column has multiple candidate tables (is ambiguous).
|
boolean |
isCalculatedColumn() |
boolean |
isColumnAlias()
Check if this column source represents a column alias (renamed column).
|
static boolean |
isColumnInTableDdl(TTable table,
String columnName)
Check if a column exists in a table's DDL definition.
|
boolean |
isCTEExplicitColumn()
Check if this column is a CTE explicit column with a different name than the underlying column.
|
boolean |
isDefinite()
Checks if this is a definite resolution (confidence = 1.0)
|
boolean |
isInferred()
Checks if this is an inferred resolution (confidence < 1.0)
|
boolean |
isRenamedByAliasList() |
boolean |
isStructFieldAccess()
Check if this is a struct field access (has evidence "struct_field_access").
|
void |
markRenamedByAliasList() |
void |
setStarMemberName(String starMemberName) |
String |
toString() |
ColumnSource |
withCandidateTables(List<TTable> candidates)
Creates a copy with candidate tables.
|
ColumnSource |
withConfidence(double newConfidence,
String newEvidence)
Deprecated.
Use
withEvidence(ResolutionEvidence) instead |
ColumnSource |
withEvidence(ResolutionEvidence newEvidence)
Creates a copy with updated ResolutionEvidence.
|
ColumnSource |
withFieldPath(FieldPath newFieldPath)
Creates a copy with a field path for deep/record field access.
|
ColumnSource |
withFieldPath(FieldPath newFieldPath,
String newEvidence)
Creates a copy with field path and updated evidence.
|
ColumnSource |
withFieldPath(List<String> segments)
Creates a copy with a field path from a list of segments.
|
public static final String EVIDENCE_ALIAS_COLUMN_VIA_STAR
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, double confidence, String evidence)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, double confidence, String evidence, TTable overrideTable)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, double confidence, String evidence, TTable overrideTable, List<TTable> candidateTables)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, double confidence, String evidence, TTable overrideTable, List<TTable> candidateTables, ResolutionEvidence evidenceDetail)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, double confidence, String evidence, TTable overrideTable, List<TTable> candidateTables, ResolutionEvidence evidenceDetail, FieldPath fieldPath)
sourceNamespace - The namespace where this column is exposedexposedName - The name by which this column is exposeddefinitionNode - The AST node where this column is definedconfidence - Confidence score [0.0, 1.0]evidence - Evidence string for this resolutionoverrideTable - Override table for traced columnscandidateTables - Candidate tables for ambiguous columnsevidenceDetail - Structured evidence detailfieldPath - Field path for deep/record field accesspublic ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, ResolutionEvidence evidenceDetail)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode, ResolutionEvidence evidenceDetail, TTable overrideTable)
public ColumnSource(INamespace sourceNamespace, String exposedName, TParseTreeNode definitionNode)
public INamespace getSourceNamespace()
public String getExposedName()
public TParseTreeNode getDefinitionNode()
public SourceLocation getDefinitionLocation()
public double getConfidence()
public String getEvidence()
public ResolutionEvidence getEvidenceDetail()
This is the preferred way to access resolution evidence as it provides:
public EvidenceType getEvidenceType()
public boolean hasDefiniteEvidence()
public TTable getFinalTable()
SELECT title FROM (SELECT * FROM books) sub
For the 'title' column in outer SELECT:
- TObjectName.getSourceTable() → TTable for subquery 'sub' (immediate source)
- ColumnSource.getFinalTable() → TTable for 'books' (final physical table)
For calculated columns in subqueries (expressions like START_DT - x AS alias),
this returns null because such calculated columns don't originate from a physical
table - they are derived values computed in the subquery.
For aliased columns in subqueries (e.g., SELECT t.id AS col1 FROM my_table t),
this traces through the alias to find the physical table, because the data still
originates from the physical table even though the column has been renamed.
Note: For CTEs, calculated columns ARE the CTE's own columns, so they trace to the CTE itself (handled by CTENamespace.getFinalTable()).
TObjectName.getSourceTable()public String getFinalColumnName()
When a column is aliased in a subquery (e.g., SELECT t.id AS col1),
the exposed name is col1 but the original column in the physical table
is id. This method returns id so callers can pair the correct
column name with the physical table returned by getFinalTable().
For multi-level aliases (e.g., SELECT ADCS_MSISDN FROM (SELECT MSISDN AS ADCS_MSISDN FROM t) sub),
this recursively traces through all levels to find the original column name (MSISDN).
public List<TTable> getAllFinalTables()
For columns from UNION queries, this returns tables from ALL branches,
not just the first one. This is essential for proper lineage tracking
where a column like actor_id in a UNION query should be linked
to actor.actor_id, actor2.actor_id, actor3.actor_id.
For regular single-table sources, this returns a single-element list
with the same table as getFinalTable().
public void markRenamedByAliasList()
public boolean isRenamedByAliasList()
public void setStarMemberName(String starMemberName)
public boolean isCalculatedColumn()
public boolean isColumnAlias()
A column is an alias if it's a simple column reference in a subquery that has been given a different name via AS or NAMED. For example:
SELECT col AS alias FROM table - alias is different from colSELECT col (NAMED alias) FROM table - Teradata NAMED syntaxSELECT alias = col FROM table - SQL Server proprietary syntaxColumn aliases are traced through in getFinalTable() to find the
physical table the data originates from, since the alias only renames the column
but the data still comes from the physical table.
public boolean isCTEExplicitColumn()
A CTE explicit column is one defined in the CTE's column list that maps to a different column name in the CTE's SELECT list. For example:
WITH cte(c1, c2) AS (SELECT id, name FROM users) SELECT c1 FROM cte -- c1 maps to 'id', names differ
CTE explicit columns should NOT trace to base tables because the explicit column name (c1) doesn't exist as an actual column in the base table (users).
public TTable getOverrideTable()
public List<TTable> getCandidateTables()
When a column could come from multiple tables (e.g., SELECT * FROM t1, t2), this returns all possible source tables. End users can iterate through this list to understand all potential sources for the column.
public boolean isAmbiguous()
public FieldPath getFieldPath()
When a column reference includes field access beyond the base column,
this returns the field path. For example, in customer.address.city,
if base column is customer, this returns a FieldPath with
segments ["address", "city"].
public boolean hasFieldPath()
public boolean isStructFieldAccess()
This is a convenience method for checking if this column source represents a struct/record field dereference operation.
public boolean isDefinite()
public boolean isInferred()
public ColumnSource withConfidence(double newConfidence, String newEvidence)
withEvidence(ResolutionEvidence) insteadpublic ColumnSource withEvidence(ResolutionEvidence newEvidence)
newEvidence - The new evidence detailpublic ColumnSource withCandidateTables(List<TTable> candidates)
public ColumnSource withFieldPath(FieldPath newFieldPath)
This method is used when resolving struct/record field access patterns
like customer.address.city. The base column is preserved as the
exposedName, and the field path captures the remaining segments.
newFieldPath - The field path segments (beyond the base column)public ColumnSource withFieldPath(List<String> segments)
Convenience method for creating a ColumnSource with a field path from a list of string segments.
segments - The field path segmentspublic ColumnSource withFieldPath(FieldPath newFieldPath, String newEvidence)
This method is used when resolving struct field access, combining both the field path and the struct_field_access evidence marker.
newFieldPath - The field path segmentsnewEvidence - The evidence string (e.g., "struct_field_access")public static boolean isColumnInTableDdl(TTable table, String columnName)
This method checks the table's column definitions (from CREATE TABLE statements parsed in the same script) to verify if the column name is defined.
table - The table to checkcolumnName - The column name to look forpublic static boolean hasTableDdl(TTable table)
table - The table to checkpublic static int getDdlVerificationStatus(TTable table, String columnName)
Returns a tri-state result:
table - The candidate table to checkcolumnName - The column name to verifypublic Map<TTable,Integer> getCandidateTableDdlStatus()
Returns a map from each candidate table to its DDL verification status: