Class Catalog
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileFormat(String qualifiedName, FileFormat fileFormat) voidbeginSessionScope(String database, String schema) Begin a per-thread session scope: untilclearSessionScope()runs on this thread, the current database/schema are read from and written to this scope only.voidEnd this thread's session scope (idempotent).voidcloneDatabase(String sourceName, String targetName) voidcreateComputePool(ComputePool pool) A real account phrases the duplicate as a generic object clash, not a pool-specific one.voidcreateDatabase(String name) voidcreateRole(String name) voidcreateStage(String name, StageType type, String url) voidcreateStage(String name, StageType type, String url, String fileFormat, boolean encryption, String comment) voidvoidvoidcreateUser(String name) voidcreateUser(String name, String password, String defaultRole) voidcreateWarehouse(String name, WarehouseSize size) The role to record as owner on newly-created objects: the session's current role, else SYSADMIN.String[]This thread's active scope (or null) — capture before nesting another scope on the same thread.The user whose stage@~resolves to: the session's current user, else PUBLIC.databaseExact(String name) The database a SQL reference names, matched EXACTLY.voiddropComputePool(String name) voiddropDatabase(String name, boolean cascade) voiddropFileFormat(String name) voidvoiddropSchema(String databaseName, String schemaName, boolean cascade) Drop a schema and move the session off it when it was the current one.voidvoidvoidvoiddropWarehouse(String name) findAggregationPolicy(String qualifiedName) The aggregation policy a possibly-qualified name resolves to, or null when nothing does.findContact(String qualifiedName) The contact a possibly-qualified name resolves to, or null when nothing does.findJoinPolicy(String qualifiedName) The join policy a possibly-qualified name resolves to, or null when nothing does.findMaskingPolicy(String qualifiedName) The masking policy a possibly-qualified name resolves to, or null when nothing does.findProjectionPolicy(String qualifiedName) The projection policy a possibly-qualified name resolves to, or null when nothing does.findRowAccessPolicy(String qualifiedName) The row access policy a possibly-qualified name resolves to, or null when nothing does — the lookup the attachment statements need before they may touch the object they attach to.getComputePool(String name) Every pool, sorted by name — the order SHOW COMPUTE POOLS lists them in.getDatabase(String name) A database by name, matched ignoring case — the INTERNAL Java API, used by engine plumbing and by tests that nametest_dbin lower case.getFileFormat(String name) getObjectOwnerRole(String objectType, String objectName) The owner role of a schema-level object, for ownership-based authorization.getObjectTagValue(String tagName, String objectName, String domain) Read the value of a tag set on an object (SYSTEM$GET_TAG); null if the object or tag is absent.getWarehouse(String name) voidgrantColumnPrivilegeToRole(String privilege, String objectType, String objectName, String columnName, String roleName) voidgrantColumnPrivilegeToUser(String privilege, String objectType, String objectName, String columnName, String userName) voidgrantPrivilegeToRole(String privilege, String objectType, String objectName, String roleName) voidgrantPrivilegeToUser(String privilege, String objectType, String objectName, String userName) voidgrantRoleToRole(String grantedRoleName, String targetRoleName) voidgrantRoleToUser(String roleName, String userName) booleanhasComputePool(String name) booleanWhether that service exists, without the throw — what CREATE … IF NOT EXISTS asks.booleanhasFileFormat(String name) booleanhasTableAsWritten(QualifiedName written) Whether the table a SQL reference names exists, asked without the throw.booleanbooleanWhether a user of this name exists, for callers that must not throw on a miss.booleanhasWarehouse(String name) Whether that warehouse exists, without the throw — for the statements that must VALIDATE a warehouse they only reference.booleanisAggregationPolicyInUse(String policyName) True when an aggregation policy is attached to any table — live refuses to drop or replace one.booleanisJoinPolicyInUse(String policyName) True when a join policy is attached to any table — live refuses to drop or replace one.booleanisPolicyInUse(String policyName, boolean masking) True when a masking policy (masking) or row access policy is attached to any column, table or view — Snowflake refuses to drop or replace such a policy (live-verified).booleanisProjectionPolicyInUse(String policyName) True when a projection policy is attached to any column — live refuses to drop or replace one.booleanisSystemRole(String roleName) Check if a role is a system rolevoidMove a table to a (possibly different) schema/database, optionally renaming it — the qualified-target form ofALTER TABLE ... RENAME TO db.schema.name.voidMove a view to a (possibly different) schema/database under a new name — ALTER VIEW's RENAME TO, whose new name the session's context places.qualifiedObjectName(String qualifiedName) A schema-level object's name spelled in full —database.schema.OBJECT— resolving however much of the path was written against the session, the way a reference to it resolves.voidrecordDropped(String key, DroppedObject dropped) Record a dropped object's snapshot under "KIND:fqName" so a subsequent UNDROP can restore it.voidrenameAggregationPolicy(String oldName, String newName) voidrenameDatabase(String oldName, String newName) voidrenameJoinPolicy(String oldName, String newName) voidrenameMaskingPolicy(String oldName, String newName) voidrenameProjectionPolicy(String oldName, String newName) voidrenameRole(String oldName, String newName) voidrenameRowAccessPolicy(String oldName, String newName) voidrenameStage(String name, String newName) ALTER STAGE … RENAME TO — rekey the schema's map and rename the object itself.voidrenameTable(String qualifiedName, String newName) voidvoidrenameUser(String oldName, String newName) voidrenameView(String qualifiedName, String newName) voidrenameWarehouse(String oldName, String newName) requireOwningSchema(QualifiedName written) The schema an object name passes through, which must exist even where the object itself need not: DROP … IF EXISTS and TRUNCATE … IF EXISTS forgive only the object's own absence (live-verified).resolveCortexSearchService(String qualifiedName) A Cortex search service by name, however much of the path the caller wrote.resolveSchema(QualifiedName written) resolveSchema(String qualifiedName) resolveStream(String qualifiedName) Resolve a stream by its (optionally schema- or db-qualified) name against the current context —SYSTEM$STREAM_HAS_DATA('SCHEMA.STREAM')passes the qualified text at runtime.resolveTable(QualifiedName written) resolveTable(String qualifiedName) resolveTableAsWritten(QualifiedName written, String reportedKind) resolveTableAsWritten(String qualifiedName, String reportedKind) The table a QUERY or DML statement named, with a miss reported the way Snowflake reports it there: the name exactly as the writer spelled it when they spelled it bare, expanded in full when they supplied any qualifier at all, and underreportedKind—Objectfor a FROM clause, an UPDATE or a DELETE,Tablefor INSERT and DESCRIBE.resolveTableAsWritten(String qualifiedName, String reportedKind, String lookup) resolveTableAsWritten(String, String)for a lookup a query does not make.resolveView(QualifiedName written) resolveView(String qualifiedName) voidrestoreContext(String databaseName, String schemaName) Restore a previously-saved (database, schema) pair WITHOUT re-validating it — for unwinding a CALL or a task back to the caller's context.voidrestoreDatabase(Database database) Re-insert a previously-dropped database object (UNDROP DATABASE).voidrestoreSessionScope(String[] scope) Reinstate a scope captured bycurrentSessionScope()(null clears), unwinding a nested scope.voidrevokeColumnPrivilegeFromRole(String privilege, String objectType, String objectName, String columnName, String roleName) voidrevokeColumnPrivilegeFromUser(String privilege, String objectType, String objectName, String columnName, String userName) voidrevokePrivilegeFromRole(String privilege, String objectType, String objectName, String roleName) voidrevokePrivilegeFromUser(String privilege, String objectType, String objectName, String userName) voidrevokeRoleFromRole(String revokedRoleName, String targetRoleName) voidrevokeRoleFromUser(String roleName, String userName) voidsetAccountLocator(String locator) The account locator a name may lead with — set from the engine's configuration, upper-cased as a bare identifier folds; null leaves every name as written.voidsetS3PathResolver(S3PathResolver s3PathResolver) Set the resolver used to map s3:// stage URLs to local paths (seeS3PathResolver).voidsetSessionContext(SessionContext sessionContext) Set the session context used to stamp object ownership at CREATE time.voidswapTables(String nameA, String nameB) ALTER TABLE a SWAP WITH b — the two tables exchange names in place, so each keeps its own columns, constraints and comment but answers to the other's name (and schema).takeDropped(String key) Remove and return the most recent dropped-object snapshot for "KIND:fqName", or null if none.voiduseDatabase(String name) voiduseDatabaseReference(String resolvedName) USE DATABASE as a SQL reference resolves it — EXACTLY: the reference's resolved name (a bare one folded to upper case, a quoted one verbatim) must equal a stored name, so"audit_db"does not select AUDIT_DB and a baremixeddbdoes not select"MiXedDb".voidUSE ROLE <name>: switch the session's primary role; errors if the role does not exist.voidvoiduseSchemaReference(String resolvedDatabase, String resolvedSchema) USE SCHEMA as a SQL reference resolves it, exactly asuseDatabaseReference(java.lang.String)does, for a schema of the named database or, with no database part, of the current one.voiduseSecondaryRoles(String spec) USE SECONDARY ROLES {ALL | NONE | <role>}: adjust which non-primary roles' privileges are active.voiduseWarehouse(String name) String[]withoutAccount(String[] parts, int objectParts) An object name without the account locator it may lead with.
-
Constructor Details
-
Catalog
public Catalog()
-
-
Method Details
-
createDatabase
-
cloneDatabase
-
dropDatabase
-
dropSchema
Drop a schema and move the session off it when it was the current one.★ THE SCHEMA FALLS BACK TO PUBLIC, not to nothing — live leaves the DATABASE alone and puts the schema back to PUBLIC, which is the same landing place
useDatabase(java.lang.String)chooses. Only dropping the database itself clears both.- Parameters:
databaseName- the schema's databaseschemaName- the schema to dropcascade- whether to drop the schema's contents with it
-
getDatabase
A database by name, matched ignoring case — the INTERNAL Java API, used by engine plumbing and by tests that nametest_dbin lower case. SQL resolution must not come through here; seedatabaseExact(java.lang.String). -
databaseExact
The database a SQL reference names, matched EXACTLY.A reference resolves to a name first — bare folds to upper, quoted keeps its case — and that name must then equal a stored one. Live rejects
mixedDbfor a database created as"mixedDb"withDatabase 'MIXEDDB' does not exist or not authorized., naming the resolved form rather than the spelling; so does this. -
isPolicyInUse
True when a masking policy (masking) or row access policy is attached to any column, table or view — Snowflake refuses to drop or replace such a policy (live-verified). Attachment names may be stored bare or qualified, so the comparison uses the last segment. -
getAllDatabases
-
beginSessionScope
Begin a per-thread session scope: untilclearSessionScope()runs on this thread, the current database/schema are read from and written to this scope only. The concurrent front-end brackets every statement with begin/clear so sessions cannot see each other's context. -
clearSessionScope
public void clearSessionScope()End this thread's session scope (idempotent). Read the final values via the getters first. -
currentSessionScope
This thread's active scope (or null) — capture before nesting another scope on the same thread. -
restoreSessionScope
Reinstate a scope captured bycurrentSessionScope()(null clears), unwinding a nested scope. -
useDatabase
-
restoreContext
Restore a previously-saved (database, schema) pair WITHOUT re-validating it — for unwinding a CALL or a task back to the caller's context. Re-runninguseDatabase(java.lang.String)/useSchema(java.lang.String)there can throw (the objects may have been dropped meanwhile, or the saved pair may no longer be valid), and an exception raised while unwinding replaces the statement's real result and escapes the procedure's own EXCEPTION handler. Names that still match an object are restored in its stored spelling. -
useSchema
-
useDatabaseReference
USE DATABASE as a SQL reference resolves it — EXACTLY: the reference's resolved name (a bare one folded to upper case, a quoted one verbatim) must equal a stored name, so"audit_db"does not select AUDIT_DB and a baremixeddbdoes not select"MiXedDb". A miss names nothing — live answers every failed USE with the same sentence — and leaves the context as it was.- Parameters:
resolvedName- the database reference, resolved
-
useSchemaReference
USE SCHEMA as a SQL reference resolves it, exactly asuseDatabaseReference(java.lang.String)does, for a schema of the named database or, with no database part, of the current one. Both parts resolve before anything moves, so a missing schema leaves the current database unchanged too.- Parameters:
resolvedDatabase- the database part, resolved, or null for the current databaseresolvedSchema- the schema part, resolved
-
getCurrentDatabase
-
getCurrentSchema
-
resolveTable
-
setAccountLocator
The account locator a name may lead with — set from the engine's configuration, upper-cased as a bare identifier folds; null leaves every name as written.- Parameters:
locator- the locator CURRENT_ACCOUNT() answers with
-
withoutAccount
An object name without the account locator it may lead with. A fully qualified name has up toobjectPartsparts (three for a table or view, two for a schema); live accepts one more in front when it is THIS account's locator —am68630.db.s.t, a quoted"AM68630"too — and resolves the rest exactly as the shorter spelling. Any other extra part, a wrong account or a fifth part, names nothing and is refused in the sentence live gives.- Parameters:
parts- the resolved parts (a bare one folded, a quoted one verbatim)objectParts- how many parts the name may have without the account- Returns:
- the parts naming the object within the account
-
resolveTable
-
resolveTableAsWritten
The table a QUERY or DML statement named, with a miss reported the way Snowflake reports it there: the name exactly as the writer spelled it when they spelled it bare, expanded in full when they supplied any qualifier at all, and underreportedKind—Objectfor a FROM clause, an UPDATE or a DELETE,Tablefor INSERT and DESCRIBE. Measured on a real account:SELECT 1 FROM nosuchanswersObject 'NOSUCH' …whileSELECT 1 FROM s.nosuchanswersObject 'DB.S.NOSUCH' …. DDL differs — it always spells the name in full — which is what plainresolveTable(QualifiedName)does. -
resolveTableAsWritten
resolveTableAsWritten(String, String)for a lookup a query does not make. With no current database, a schema-qualified name is refused naming that lookup: CLONE for a CLONE source, DUPLICATE for a LIKE source, where every FROM clause says SELECT (live-verified).- Parameters:
lookup- what the refusal names when the session cannot place a schema-qualified name
-
resolveTableAsWritten
-
hasTableAsWritten
Whether the table a SQL reference names exists, asked without the throw. False for a missing table and for a name the session cannot place: a bare one with no current schema, or a schema-qualified one with no current database. A database or schema the reference does name must still exist.- Parameters:
written- the reference, resolved part by part- Returns:
- whether the table exists
-
resolveView
-
resolveView
-
resolveCortexSearchService
A Cortex search service by name, however much of the path the caller wrote. The owning schema is resolved first so a missing DATABASE or SCHEMA is reported as such, and only a resolvable schema that lacks the service reports the service missing. -
resolveCortexSearchService
-
hasCortexSearchService
Whether that service exists, without the throw — what CREATE … IF NOT EXISTS asks. -
requireOwningSchema
The schema an object name passes through, which must exist even where the object itself need not: DROP … IF EXISTS and TRUNCATE … IF EXISTS forgive only the object's own absence (live-verified). A name the session cannot place is refused naming the statement.- Parameters:
written- the object's name, resolved part by part- Returns:
- the schema that holds, or would hold, the object
-
resolveSchema
-
resolveSchema
-
createWarehouse
-
dropWarehouse
-
createComputePool
A real account phrases the duplicate as a generic object clash, not a pool-specific one. -
hasComputePool
-
getComputePool
-
dropComputePool
-
getComputePools
Every pool, sorted by name — the order SHOW COMPUTE POOLS lists them in. -
hasWarehouse
Whether that warehouse exists, without the throw — for the statements that must VALIDATE a warehouse they only reference. -
getWarehouse
-
getAllWarehouses
-
useWarehouse
-
getCurrentWarehouse
-
getCurrentWarehouseObject
-
setS3PathResolver
Set the resolver used to map s3:// stage URLs to local paths (seeS3PathResolver). -
setSessionContext
Set the session context used to stamp object ownership at CREATE time. -
currentRoleForOwner
The role to record as owner on newly-created objects: the session's current role, else SYSADMIN. -
getObjectOwnerRole
The owner role of a schema-level object, for ownership-based authorization. Returns null when the type is not one that carries an owner here, or the object cannot be resolved. -
currentUserForStage
The user whose stage@~resolves to: the session's current user, else PUBLIC. -
useRole
USE ROLE <name>: switch the session's primary role; errors if the role does not exist.The refusal NAMES NOTHING — live answers "Object does not exist, or operation cannot be performed." for a role that is not there, without quoting the name the way its object-not-found sentences do elsewhere. That is deliberate on a real account: a role a session cannot use is indistinguishable from one that does not exist, so the message cannot confirm either.
-
useSecondaryRoles
USE SECONDARY ROLES {ALL | NONE | <role>}: adjust which non-primary roles' privileges are active. -
recordDropped
Record a dropped object's snapshot under "KIND:fqName" so a subsequent UNDROP can restore it. -
takeDropped
Remove and return the most recent dropped-object snapshot for "KIND:fqName", or null if none. -
restoreDatabase
Re-insert a previously-dropped database object (UNDROP DATABASE). -
getObjectTagValue
Read the value of a tag set on an object (SYSTEM$GET_TAG); null if the object or tag is absent. -
createStage
-
createStage
-
dropStage
-
renameStage
ALTER STAGE … RENAME TO — rekey the schema's map and rename the object itself. -
getStage
-
resolveStream
Resolve a stream by its (optionally schema- or db-qualified) name against the current context —SYSTEM$STREAM_HAS_DATA('SCHEMA.STREAM')passes the qualified text at runtime. Returns null when the schema or stream does not exist. -
addFileFormat
-
getFileFormat
-
hasFileFormat
-
dropFileFormat
-
getPipe
-
getAllStages
-
createTag
-
createTag
-
dropTag
-
getTag
-
hasTag
-
getAllTags
-
renameTag
-
renameMaskingPolicy
-
renameJoinPolicy
-
renameAggregationPolicy
-
renameProjectionPolicy
-
renameRowAccessPolicy
-
findRowAccessPolicy
The row access policy a possibly-qualified name resolves to, or null when nothing does — the lookup the attachment statements need before they may touch the object they attach to.- Parameters:
qualifiedName- the policy name as written: bare, schema-qualified or fully qualified- Returns:
- the policy, or null when the name resolves to no policy in that schema
-
findJoinPolicy
The join policy a possibly-qualified name resolves to, or null when nothing does.- Parameters:
qualifiedName- the policy name as written- Returns:
- the policy, or null when the name resolves to none in that schema
-
isJoinPolicyInUse
True when a join policy is attached to any table — live refuses to drop or replace one. -
findAggregationPolicy
The aggregation policy a possibly-qualified name resolves to, or null when nothing does.- Parameters:
qualifiedName- the policy name as written- Returns:
- the policy, or null when the name resolves to none in that schema
-
isAggregationPolicyInUse
True when an aggregation policy is attached to any table — live refuses to drop or replace one. -
findProjectionPolicy
The projection policy a possibly-qualified name resolves to, or null when nothing does.- Parameters:
qualifiedName- the policy name as written- Returns:
- the policy, or null when the name resolves to none in that schema
-
isProjectionPolicyInUse
True when a projection policy is attached to any column — live refuses to drop or replace one. -
findContact
The contact a possibly-qualified name resolves to, or null when nothing does.- Parameters:
qualifiedName- the contact name as written: bare, schema-qualified or fully qualified- Returns:
- the contact, or null when the name resolves to none in that schema
-
findMaskingPolicy
The masking policy a possibly-qualified name resolves to, or null when nothing does. A name whose SCHEMA is missing does not answer null — it raises the schema's own refusal, which is what live answers there too.- Parameters:
qualifiedName- the policy name as written: bare, schema-qualified or fully qualified- Returns:
- the policy, or null when the name resolves to no policy in that schema
-
qualifiedObjectName
A schema-level object's name spelled in full —database.schema.OBJECT— resolving however much of the path was written against the session, the way a reference to it resolves. Live reports an attached policy this way whatever the attaching statement wrote, so a name recorded for later display is qualified once, when it is attached, rather than at every read.- Parameters:
qualifiedName- the name as written: bare, schema-qualified or already fully qualified- Returns:
- the fully qualified name, upper-cased in its last part as the reference resolved it
-
createUser
-
createUser
-
dropUser
-
hasUser
Whether a user of this name exists, for callers that must not throw on a miss. -
getUser
-
getAllUsers
-
createRole
-
dropRole
-
isSystemRole
Check if a role is a system role -
getRole
-
getAllRoles
-
grantRoleToUser
-
revokeRoleFromUser
-
grantPrivilegeToRole
-
revokePrivilegeFromRole
-
grantPrivilegeToUser
-
revokePrivilegeFromUser
-
grantColumnPrivilegeToRole
-
revokeColumnPrivilegeFromRole
-
grantColumnPrivilegeToUser
-
revokeColumnPrivilegeFromUser
-
grantRoleToRole
-
revokeRoleFromRole
-
renameDatabase
-
renameTable
-
swapTables
ALTER TABLE a SWAP WITH b — the two tables exchange names in place, so each keeps its own columns, constraints and comment but answers to the other's name (and schema). Both must exist; resolution failures throw before anything mutates. -
moveTable
public void moveTable(String sourceQualifiedName, String targetDatabase, String targetSchema, String newName) Move a table to a (possibly different) schema/database, optionally renaming it — the qualified-target form ofALTER TABLE ... RENAME TO db.schema.name. The destination database and schema must already exist (elsegetDatabase(java.lang.String)/getSchemathrow), and no table of the new name may already exist there. Membership is checked before any mutation, so a rejected move leaves the catalog untouched. -
moveView
public void moveView(String sourceQualifiedName, String targetDatabase, String targetSchema, String newName) Move a view to a (possibly different) schema/database under a new name — ALTER VIEW's RENAME TO, whose new name the session's context places. The destination must exist and hold no view of that name, both checked before anything changes; a move within the view's own schema is a rename. -
renameView
-
renameUser
-
renameRole
-
renameWarehouse
-