public class GlobalScope extends AbstractScope
Responsibilities:
When resolving table names, this scope uses QualifiedNameResolver
to properly handle partial names (e.g., just "table" or "schema.table")
by applying default catalog/schema from TSQLEnv.
Example: With default catalog="mydb" and schema="dbo":
QualifiedNameResolver,
QualifiedNamenode, parent, scopeType| Constructor and Description |
|---|
GlobalScope(gudusoft.gsqlparser.compiler.TContext globalContext,
INameMatcher nameMatcher) |
GlobalScope(gudusoft.gsqlparser.compiler.TContext globalContext,
INameMatcher nameMatcher,
TSQLEnv sqlEnv,
EDbVendor vendor)
Create a GlobalScope with SQL environment for qualified name resolution.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addGlobalTable(String qualifiedNameStr,
INamespace tableNamespace)
Add a globally accessible table (from metadata).
|
void |
addGlobalTable(String catalog,
String schema,
String tableName,
INamespace tableNamespace)
Add a globally accessible table with explicit catalog/schema/name.
|
String |
getDefaultCatalog()
Get the default catalog from SQL environment.
|
String |
getDefaultSchema()
Get the default schema from SQL environment.
|
gudusoft.gsqlparser.compiler.TContext |
getGlobalContext() |
INameMatcher |
getNameMatcher() |
QualifiedNameResolver |
getQualifiedNameResolver()
Get the qualified name resolver.
|
TSQLEnv |
getSqlEnv()
Get the SQL environment.
|
EDbVendor |
getVendor()
Get the database vendor.
|
List<INamespace> |
getVisibleNamespaces()
Default implementation: delegate to parent
|
void |
resolve(List<String> names,
INameMatcher matcher,
boolean deep,
IResolved resolved)
Default implementation: delegate to parent
|
INamespace |
resolveTable(String tableName)
Default implementation: delegate to parent
|
void |
setSqlEnv(TSQLEnv sqlEnv)
Set the SQL environment for qualified name resolution.
|
void |
setVendor(EDbVendor vendor)
Set the database vendor.
|
String |
toString() |
addChild, fullyQualify, getChildren, getNode, getParent, getScopeType, isWithinpublic GlobalScope(gudusoft.gsqlparser.compiler.TContext globalContext, INameMatcher nameMatcher)
public GlobalScope(gudusoft.gsqlparser.compiler.TContext globalContext, INameMatcher nameMatcher, TSQLEnv sqlEnv, EDbVendor vendor)
globalContext - The global parser contextnameMatcher - The name matcher for case sensitivitysqlEnv - The SQL environment with default catalog/schemavendor - The database vendorpublic void setSqlEnv(TSQLEnv sqlEnv)
sqlEnv - The SQL environment with default catalog/schemapublic void addGlobalTable(String qualifiedNameStr, INamespace tableNamespace)
The qualified name should be in the format "catalog.schema.table" or "schema.table" or just "table". The name will be parsed and stored for proper matching later.
qualifiedNameStr - The qualified table name stringtableNamespace - The namespace representing the tablepublic void addGlobalTable(String catalog, String schema, String tableName, INamespace tableNamespace)
catalog - The catalog name (nullable)schema - The schema name (nullable)tableName - The table name (required)tableNamespace - The namespace representing the tablepublic INamespace resolveTable(String tableName)
AbstractScoperesolveTable in interface IScoperesolveTable in class AbstractScopetableName - Table name or aliaspublic String getDefaultCatalog()
public String getDefaultSchema()
public void resolve(List<String> names, INameMatcher matcher, boolean deep, IResolved resolved)
AbstractScoperesolve in interface IScoperesolve in class AbstractScopenames - Name parts (e.g., ["schema", "table", "column"])matcher - Name matcher for case sensitivity rulesdeep - Whether to recursively resolve into record fieldsresolved - Callback to collect all matchespublic List<INamespace> getVisibleNamespaces()
AbstractScopegetVisibleNamespaces in interface IScopegetVisibleNamespaces in class AbstractScopepublic gudusoft.gsqlparser.compiler.TContext getGlobalContext()
public INameMatcher getNameMatcher()
public QualifiedNameResolver getQualifiedNameResolver()
public String toString()
toString in class AbstractScope