public class DlineageUtil extends Object
| Constructor and Description |
|---|
DlineageUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
columnSegmentOf(String column)
The RAW column (last) segment of a reference —
getColumnName(String)'s
extraction (naive last-dot split, trim, whole-string fallback) WITHOUT the
normalization, for callers that canonically compare a segment against a
differently-shaped operand. |
static boolean |
compareColumnIdentifier(String source,
String target) |
static boolean |
compareIdentifier(String source,
String target,
ESQLDataObjectType sqlDataObjectType) |
static boolean |
compareTableIdentifier(String source,
String target) |
static SqlInfo[] |
convertSQL(File file,
String json) |
static sourceColumn |
copySourceColumn(sourceColumn oldSourceName) |
static String |
decodeAliasIdentifier(String alias)
Decode a delimited identifier that sits in ALIAS position.
|
static String |
decodeColumnIdentifier(String name)
Decode a delimited COLUMN identifier to the name a catalog stores, keeping
the author's letter case:
[Volgorde], "Volgorde",
`Volgorde` and the SQL Server legacy alias form 'Volgorde'
all become Volgorde; escapes resolve ([Esc]]aped] →
Esc]aped). |
static String |
getColumnName(String column)
NORMALIZED display form of the column (last) segment of a model reference (naive
last-dot split).
|
static String |
getColumnName(TObjectName column)
NORMALIZED display form of the column (last) segment of an AST object name.
|
static String |
getColumnNameOnly(String columnName) |
static String |
getFunctionNameWithArgNum(TFunctionCall function) |
static String |
getIdentifierFunctionName(table function) |
static String |
getIdentifierNormalColumnName(String name)
Legacy display/normal-name form of a column reference (global analysis vendor).
|
static String |
getIdentifierNormalColumnName(String name,
EDbVendor dbVendor)
Legacy display/normal-name form — for equality use
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) /
sameColumnSegment(java.lang.String, java.lang.String) / sameColumnName(gudusoft.gsqlparser.nodes.TObjectName, gudusoft.gsqlparser.nodes.TObjectName), not string compares on
this result. |
static String |
getIdentifierNormalFunctionName(String name)
Legacy display/normal-name form of a function reference — for equality use
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) with dotFunction, not string compares on this result. |
static String |
getIdentifierNormalName(String name,
ESQLDataObjectType sqlDataObjectType)
Legacy display/normal-name form (global analysis vendor) — for equality use
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) / sameQualifiedName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String), not string compares on this result. |
static String |
getIdentifierNormalTableName(String name)
Legacy display/normal-name form of a table reference (global analysis vendor;
dblink and call-shaped names keep their suffix).
|
static String |
getIdentifierOraclePackageNameWithArgNum(oraclePackage pkg) |
static String |
getIdentifierProcedureNameWithArgNum(procedure procedure) |
static TSelectSqlStatement |
getLeftStmt(TSelectSqlStatement stmt) |
static String |
getProcedureNameWithArgNum(TStoredProcedureSqlStatement stmt) |
static String |
getProcedureNameWithArgs(TStoredProcedureSqlStatement stmt) |
static String |
getProcedureNameWithInputArgNum(TStoredProcedureSqlStatement stmt) |
static TObjectName |
getProcedureOrFunctionName(TStoredProcedureSqlStatement stmt) |
static String |
getProcedureParentName(TCustomSqlStatement stmt) |
static String |
getQualifiedTableName(table table) |
static String |
getSimpleTableName(String tableName) |
static String |
getTableDatabase(String tableName) |
static String |
getTableFullName(String tableName) |
static String |
getTableFullNameWithDefaultSchema(String tableName) |
static String |
getTableSchema(String tableName) |
static String |
getTableSchema(Table tableModel) |
static String |
getTableServer(String tableName) |
static String |
getTableSQLEnvKey(Table tableModel) |
static TCustomSqlStatement |
getTopBasicStmt(TCustomSqlStatement stmt) |
static TCustomSqlStatement |
getTopStmt(TCustomSqlStatement stmt) |
static boolean |
hasUsableCoordinate(String coordinate)
Whether a serialized coordinate ("[line,col,offset],[line,col,offset]...")
points at a real reference site.
|
static String |
identityScopeKey(String legacyScopeKey,
RoutineIdentity identity)
B1 (routine-summary-scc-design §3): overload-discriminating scope key.
|
static boolean |
isBuiltInFunctionName(String functionName) |
static boolean |
isKeyword(String objectName) |
static boolean |
isProcedureExcluded(String fullName) |
static boolean |
isQuote(String column) |
static boolean |
isTempTable(Table tableModel,
EDbVendor vendor) |
static String |
normalizeColumnName(String name)
Legacy uppercase-collapsed normal form (global analysis vendor) — for equality use
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) / sameColumnSegment(java.lang.String, java.lang.String), not string compares on this result. |
static String |
normalizeColumnName(String name,
EDbVendor dbVendor)
Legacy uppercase-collapsed normal form — for equality use
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) /
sameColumnSegment(java.lang.String, java.lang.String), not string compares on this result. |
static boolean |
sameColumnName(String a,
TObjectName b)
Mixed operand shapes: model name string vs AST object name.
|
static boolean |
sameColumnName(TObjectName a,
TObjectName b)
Canonical counterpart of comparing
getColumnName(TObjectName) results. |
static boolean |
sameColumnSegment(String a,
String b)
Canonical equality of the column (last) segments of two references — the
canonical counterpart of comparing
getColumnName(String) results:
same naive last-dot split, same trim and empty-segment fallback, but the raw
segments go to the canonical engine instead of normalize-then-equalsIgnoreCase. |
static boolean |
sameName(ESQLDataObjectType objectType,
String a,
String b)
Single-segment identifier equality via the unified façade, using the bound
global analysis vendor; falls back to case-insensitive comparison when no
vendor is bound (model classes used outside an analysis run).
|
static boolean |
sameQualifiedName(ESQLDataObjectType objectType,
String a,
String b)
Like
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) but for possibly-qualified names; routes through the
segmenting SQLUtil#compareIdentifier. |
static String |
stripQuotesFromQualifiedName(String qualifiedName) |
static boolean |
supportFunctionOverride(EDbVendor vendor) |
public DlineageUtil()
public static boolean hasUsableCoordinate(String coordinate)
public static boolean compareIdentifier(String source, String target, ESQLDataObjectType sqlDataObjectType)
public static boolean compareColumnIdentifier(String source, String target)
public static boolean compareTableIdentifier(String source, String target)
public static boolean sameName(ESQLDataObjectType objectType, String a, String b)
public static boolean sameQualifiedName(ESQLDataObjectType objectType, String a, String b)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) but for possibly-qualified names; routes through the
segmenting SQLUtil#compareIdentifier.public static boolean sameColumnSegment(String a, String b)
getColumnName(String) results:
same naive last-dot split, same trim and empty-segment fallback, but the raw
segments go to the canonical engine instead of normalize-then-equalsIgnoreCase.public static boolean sameColumnName(TObjectName a, TObjectName b)
getColumnName(TObjectName) results.public static boolean sameColumnName(String a, TObjectName b)
public static String columnSegmentOf(String column)
getColumnName(String)'s
extraction (naive last-dot split, trim, whole-string fallback) WITHOUT the
normalization, for callers that canonically compare a segment against a
differently-shaped operand.public static String decodeColumnIdentifier(String name)
[Volgorde], "Volgorde",
`Volgorde` and the SQL Server legacy alias form 'Volgorde'
all become Volgorde; escapes resolve ([Esc]]aped] →
Esc]aped). Vendor- and role-aware, so a spelling that is not a
delimiter for the analysis vendor is left alone.
Used for the column names dlineage PUBLISHES, so that view columns and
relationship endpoints carry the same identifier a consumer finds in
sys.columns instead of a syntactic spelling it has to strip
itself (GitHub issue #704). Unrecognized or malformed input is returned
unchanged.
Only call this on a string of identifier provenance — a
TObjectName column token or a TAliasClause alias name.
A string CONSTANT reaches the model as quoted text too
('literal value' becomes a result-set column name), and decoding
one would corrupt the value it carries.
Nothing is decoded on a vendor whose delimiters carry identity.
Quoting is not always cosmetic: where a vendor case-folds UNQUOTED names,
the delimiters are what mark a name as case-exact, so Oracle
"Purchase Frequency" and Purchase Frequency (which folds
to PURCHASE FREQUENCY) are two DIFFERENT columns, and decoding
would rename the column rather than clean up its spelling. Such a vendor
is skipped ENTIRELY, by delimitersAreCosmetic(gudusoft.gsqlparser.EDbVendor), rather than
name-by-name: "DESCRIPTION" happens to fold to itself and could be
decoded safely, but decoding it while "Mixed Case" keeps its
quotes would publish two spelling conventions in one Oracle document and
leave consumers no single rule to apply. SQL Server — where [x],
"x", 'x' and x are all one case-insensitive column
— is cosmetic throughout, which is why issue #704 is a SQL Server issue.
A name whose payload contains a dot keeps its delimiters, even
on a vendor that passes the test above. Model names double as keys in the
dot-delimited qualified-name domain that SQLUtil#parseNames
segments, where the delimiters are what stop "name.dot" from
reading as name qualified by dot (the invariant
SQLUtil#quoteDottedName exists to keep). Publishing the decoded
form there cost a real CTAS lineage edge in the Snowflake corpus — a
downstream re-split renamed the target column to dot and dropped
its dependency.
In both held-back cases the name is returned exactly as written, so a consumer still has to decode it; that is strictly better than dropping an edge or renaming a column to improve a spelling.
SQLUtil#decodeDelimitedNamepublic static String decodeAliasIdentifier(String alias)
Same policy as decodeColumnIdentifier(java.lang.String), plus the vendor-blind
apostrophe form: several vendors accept a string literal as a column
alias (SELECT c AS 'myTime' is legal MySQL), and in alias position
there is no ambiguity with a value literal to protect against — a
TAliasClause has already proved this token names a column. The
column-reference codec cannot make that call, because for MySQL an
apostrophe delimits a STRING, not an identifier.
The apostrophe branch also preserves what
SQLUtil.trimSingleQuote did here before issue #704: without it,
routing aliases through the column codec would REGRESS MySQL
AS 'myTime' from myTime back to 'myTime'.
The publishable(gudusoft.gsqlparser.EDbVendor, java.lang.String) guards still apply, so this path can only ever
publish a name that survives a downstream re-decode.
public static String getIdentifierNormalColumnName(String name)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String), sameColumnSegment(java.lang.String, java.lang.String) or sameColumnName(gudusoft.gsqlparser.nodes.TObjectName, gudusoft.gsqlparser.nodes.TObjectName) —
comparing normal names with equals/equalsIgnoreCase is the pre-P0d
bug pattern. Model display-name bookkeeping is the one documented exception (see
the identifier normalization guide §6).public static String getIdentifierNormalColumnName(String name, EDbVendor dbVendor)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) /
sameColumnSegment(java.lang.String, java.lang.String) / sameColumnName(gudusoft.gsqlparser.nodes.TObjectName, gudusoft.gsqlparser.nodes.TObjectName), not string compares on
this result.public static String normalizeColumnName(String name)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) / sameColumnSegment(java.lang.String, java.lang.String), not string compares on this result.public static String normalizeColumnName(String name, EDbVendor dbVendor)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) /
sameColumnSegment(java.lang.String, java.lang.String), not string compares on this result.public static String getIdentifierNormalTableName(String name)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) / sameQualifiedName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) /
compareTableIdentifier(java.lang.String, java.lang.String).public static String getIdentifierNormalFunctionName(String name)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) with dotFunction, not string compares on this result.public static String getIdentifierNormalName(String name, ESQLDataObjectType sqlDataObjectType)
sameName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) / sameQualifiedName(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String), not string compares on this result.public static String getColumnName(TObjectName column)
sameColumnName(TObjectName, TObjectName) — it feeds the
RAW segment to the canonical engine instead of comparing normalized display text.public static String getColumnName(String column)
sameColumnSegment(String, String) —
it feeds the RAW segment to the canonical engine instead of comparing normalized
display text.public static boolean isTempTable(Table tableModel, EDbVendor vendor)
public static String getTableFullName(String tableName)
public static String getSimpleTableName(String tableName)
public static String getColumnNameOnly(String columnName)
public static String getTableSchema(String tableName)
public static String getTableServer(String tableName)
public static String getTableDatabase(String tableName)
public static String getTableFullNameWithDefaultSchema(String tableName)
public static SqlInfo[] convertSQL(File file, String json)
public static String getQualifiedTableName(table table)
public static TCustomSqlStatement getTopStmt(TCustomSqlStatement stmt)
public static TCustomSqlStatement getTopBasicStmt(TCustomSqlStatement stmt)
public static TObjectName getProcedureOrFunctionName(TStoredProcedureSqlStatement stmt)
public static String getProcedureNameWithArgs(TStoredProcedureSqlStatement stmt)
public static String getIdentifierProcedureNameWithArgNum(procedure procedure)
public static String getIdentifierOraclePackageNameWithArgNum(oraclePackage pkg)
public static String getIdentifierFunctionName(table function)
public static String getProcedureNameWithArgNum(TStoredProcedureSqlStatement stmt)
public static String getProcedureNameWithInputArgNum(TStoredProcedureSqlStatement stmt)
public static String getFunctionNameWithArgNum(TFunctionCall function)
public static String getTableSchema(Table tableModel)
public static String getTableSQLEnvKey(Table tableModel)
public static String identityScopeKey(String legacyScopeKey, RoutineIdentity identity)
public static String getProcedureParentName(TCustomSqlStatement stmt)
public static sourceColumn copySourceColumn(sourceColumn oldSourceName)
public static boolean supportFunctionOverride(EDbVendor vendor)
public static boolean isBuiltInFunctionName(String functionName)
public static TSelectSqlStatement getLeftStmt(TSelectSqlStatement stmt)
public static String stripQuotesFromQualifiedName(String qualifiedName)
public static boolean isProcedureExcluded(String fullName)