Class GlobalScope
Object
gudusoft.gsqlparser.resolver2.scope.AbstractScope
gudusoft.gsqlparser.resolver2.scope.GlobalScope
- All Implemented Interfaces:
IScope
Global scope - contains session-level objects and metadata.
This is typically the root of the scope tree.
Responsibilities:
- Access to global metadata (SQLEnv)
- Database/schema context with proper qualified name resolution
- Session variables and settings
Qualified Name Resolution
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":
- "users" matches "mydb.dbo.users"
- "hr.employees" matches "mydb.hr.employees"
- "otherdb.hr.employees" matches exactly
- See Also:
-
Field Summary
Fields inherited from class gudusoft.gsqlparser.resolver2.scope.AbstractScope
node, parent, scopeType -
Constructor Summary
ConstructorsConstructorDescriptionGlobalScope(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalTable(String qualifiedNameStr, INamespace tableNamespace) Add a globally accessible table (from metadata).voidaddGlobalTable(String catalog, String schema, String tableName, INamespace tableNamespace) Add a globally accessible table with explicit catalog/schema/name.Get the default catalog from SQL environment.Get the default schema from SQL environment.gudusoft.gsqlparser.compiler.TContextGet the qualified name resolver.Get the SQL environment.Get the database vendor.Default implementation: delegate to parentvoidresolve(List<String> names, INameMatcher matcher, boolean deep, IResolved resolved) Default implementation: delegate to parentresolveTable(String tableName) Default implementation: delegate to parentvoidSet the SQL environment for qualified name resolution.voidSet the database vendor.toString()Methods inherited from class gudusoft.gsqlparser.resolver2.scope.AbstractScope
addChild, fullyQualify, getChildren, getNode, getParent, getScopeType, isWithin
-
Constructor Details
-
GlobalScope
-
GlobalScope
public GlobalScope(gudusoft.gsqlparser.compiler.TContext globalContext, INameMatcher nameMatcher, TSQLEnv sqlEnv, EDbVendor vendor) Create a GlobalScope with SQL environment for qualified name resolution.- Parameters:
globalContext- The global parser contextnameMatcher- The name matcher for case sensitivitysqlEnv- The SQL environment with default catalog/schemavendor- The database vendor
-
-
Method Details
-
setSqlEnv
Set the SQL environment for qualified name resolution.- Parameters:
sqlEnv- The SQL environment with default catalog/schema
-
getSqlEnv
Get the SQL environment. -
setVendor
Set the database vendor. -
getVendor
Get the database vendor. -
addGlobalTable
Add a globally accessible table (from metadata).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.
- Parameters:
qualifiedNameStr- The qualified table name stringtableNamespace- The namespace representing the table
-
addGlobalTable
public void addGlobalTable(String catalog, String schema, String tableName, INamespace tableNamespace) Add a globally accessible table with explicit catalog/schema/name.- Parameters:
catalog- The catalog name (nullable)schema- The schema name (nullable)tableName- The table name (required)tableNamespace- The namespace representing the table
-
resolveTable
Description copied from class:AbstractScopeDefault implementation: delegate to parent- Specified by:
resolveTablein interfaceIScope- Overrides:
resolveTablein classAbstractScope- Parameters:
tableName- Table name or alias- Returns:
- Namespace if found, null otherwise
-
getDefaultCatalog
Get the default catalog from SQL environment. -
getDefaultSchema
Get the default schema from SQL environment. -
resolve
Description copied from class:AbstractScopeDefault implementation: delegate to parent- Specified by:
resolvein interfaceIScope- Overrides:
resolvein classAbstractScope- Parameters:
names- 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 matches
-
getVisibleNamespaces
Description copied from class:AbstractScopeDefault implementation: delegate to parent- Specified by:
getVisibleNamespacesin interfaceIScope- Overrides:
getVisibleNamespacesin classAbstractScope- Returns:
- List of visible namespaces
-
getGlobalContext
-
getNameMatcher
-
getQualifiedNameResolver
Get the qualified name resolver. -
toString
- Overrides:
toStringin classAbstractScope
-