public abstract class AbstractNamespace extends Object implements INamespace
Enhanced with reference traceability support: multiple syntactically different identifiers that refer to the same semantic column can be tracked and traced back.
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,ColumnSource> |
columnSources
Cached column sources (populated during validation) - keyed by normalized name
|
protected Map<String,ColumnSourceWithReferences> |
columnSourcesWithRefs
Enhanced column sources with reference traceability (keyed by normalized name).
|
protected int |
guessColumnStrategy
Strategy for handling ambiguous columns.
|
protected INameMatcher |
nameMatcher
Name matcher for column name comparisons
|
protected Object |
node
Associated AST node
|
protected boolean |
referenceTraceabilityEnabled
Whether reference traceability is enabled
|
protected boolean |
validated
Whether this namespace has been validated
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractNamespace(Object node) |
protected |
AbstractNamespace(Object node,
INameMatcher nameMatcher) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addColumnSource(String columnName,
ColumnSource source)
Add a column source (backward compatible - no traceability).
|
protected void |
addColumnSource(String columnName,
ColumnSource source,
TObjectName objectName)
Add a column source with reference traceability support.
|
protected boolean |
containsColumnByMatcher(Map<String,?> map,
String columnName)
Slice S1: matcher-aware
containsKey replacement for column maps
that need vendor-specific identifier rules to govern dedupe / lookup. |
protected boolean |
containsColumnNameByMatcher(Set<String> set,
String columnName)
Slice S1: matcher-aware
Set#contains replacement. |
protected abstract void |
doValidate()
Subclasses override this to perform actual validation logic.
|
void |
enableReferenceTraceability()
Enable reference traceability for this namespace.
|
protected void |
ensureValidated()
Ensure this namespace is validated before accessing column info
|
Map<String,ColumnSource> |
getAllColumnSources()
Get all column sources exposed by this namespace.
|
List<TTable> |
getAllFinalTables()
Get all final physical tables this namespace depends on.
|
Collection<ColumnSourceWithReferences> |
getAllUniqueColumns()
Get all unique columns with their references.
|
List<ColumnReference> |
getColumnReferences(String columnName)
Get all column references for a specific column.
|
ColumnSourceWithReferences |
getColumnSourceWithReferences(String columnName)
Get enhanced column source with references for a specific column.
|
int |
getGuessColumnStrategy()
Get the strategy for handling ambiguous columns.
|
INameMatcher |
getNameMatcher()
Get the name matcher used by this namespace.
|
Object |
getNode()
Get the associated AST node (TTable, TSelectSqlStatement, etc.)
|
ColumnLevel |
hasColumn(String columnName)
Check if a column exists in this namespace.
|
boolean |
isReferenceTraceabilityEnabled()
Check if reference traceability is enabled.
|
boolean |
isValidated()
Check if this namespace is validated/resolved.
|
ColumnSource |
resolveColumn(String columnName)
Resolve a column name to its source.
|
void |
setGuessColumnStrategy(int strategy)
Set the strategy for handling ambiguous columns.
|
String |
toString() |
void |
validate()
Validate/resolve this namespace.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddInferredColumn, getDisplayName, getFinalTable, getInferredColumns, getMetadataState, getSelectStatement, getSourceTable, getStarColumn, hasStarColumn, resolveColumnPath, supportsDynamicInferenceprotected boolean validated
protected Map<String,ColumnSource> columnSources
protected Map<String,ColumnSourceWithReferences> columnSourcesWithRefs
protected boolean referenceTraceabilityEnabled
protected final INameMatcher nameMatcher
protected int guessColumnStrategy
protected AbstractNamespace(Object node, INameMatcher nameMatcher)
protected AbstractNamespace(Object node)
public void setGuessColumnStrategy(int strategy)
strategy - One of TBaseType.GUESS_COLUMN_STRATEGY_* constants, or -1 to use global defaultpublic int getGuessColumnStrategy()
public Object getNode()
INamespacegetNode in interface INamespacepublic boolean isValidated()
INamespaceisValidated in interface INamespacepublic void validate()
INamespacevalidate in interface INamespaceprotected abstract void doValidate()
public void enableReferenceTraceability()
public boolean isReferenceTraceabilityEnabled()
protected void addColumnSource(String columnName, ColumnSource source, TObjectName objectName)
This method normalizes the column name and either:
columnName - original column name (may include quotes)source - the column sourceobjectName - the original AST node for traceability (may be null)protected void addColumnSource(String columnName, ColumnSource source)
columnName - original column namesource - the column sourceprotected boolean containsColumnByMatcher(Map<String,?> map, String columnName)
containsKey replacement for column maps
that need vendor-specific identifier rules to govern dedupe / lookup.
Per-vendor identifier rules differ on whether MyCol and mycol
are the same column (BigQuery / MySQL / SQL Server: yes for columns;
Oracle / Postgres unquoted: yes via folding; quoted Oracle / Postgres: no).
A raw map.containsKey(name) bypasses these rules and produces
duplicate-key drift; a fixed equalsIgnoreCase loop is wrong for
vendors where columns are case-sensitive (BigQuery tables, Oracle quoted).
This helper:
"mycol" probed by query "MYCOL" that normalizes
to "mycol"),ColumnSource.getExposedName() (when values are ColumnSource)
so quote state is preserved on quoted-sensitive dialects.Quote-state preservation (codex round 1 + round 2).
The map values must hold the original-cased identifier (with quotes).
Storage keys are also raw (= exposedName) — round 2 caught
that storing under nameMatcher.normalize(name) can collide
two matcher-distinct identifiers (e.g. Postgres quoted "mycol"
vs unquoted MYCOL both normalize to mycol) into the
same key and lose information. With raw-keyed storage, the normalize
fast-probe only hits when the stored raw key already equals the
normalized form, and in that case INameMatcher.matches(java.lang.String, java.lang.String) agrees;
the matcher loop catches the case-only-different case.
protected boolean containsColumnNameByMatcher(Set<String> set, String columnName)
Set#contains replacement. See
containsColumnByMatcher(Map, String) for the rationale.public ColumnLevel hasColumn(String columnName)
INamespacehasColumn in interface INamespacecolumnName - Column name to checkpublic ColumnSource resolveColumn(String columnName)
INamespaceresolveColumn in interface INamespacecolumnName - Column name to resolvepublic Map<String,ColumnSource> getAllColumnSources()
INamespacegetAllColumnSources in interface INamespacepublic List<ColumnReference> getColumnReferences(String columnName)
Requires reference traceability to be enabled.
columnName - the column name (normalized or original)public Collection<ColumnSourceWithReferences> getAllUniqueColumns()
Requires reference traceability to be enabled.
public ColumnSourceWithReferences getColumnSourceWithReferences(String columnName)
columnName - the column namepublic List<TTable> getAllFinalTables()
INamespacegetAllFinalTables in interface INamespaceprotected void ensureValidated()
public INameMatcher getNameMatcher()