🔴Engine
Engine is initialized with Snowflake connection and config. It is used to build, format and execute DDL commands by resolvers.
Engine is represented by class SnowDDLEngine
, which is located in engine.py
.
One engine is expected to be reused by multiple resolvers executed in the correct order.
Engine settings
Settings are represented by class SnowDDLSettings
.
You may find the most recent version of settings in settings.py
.
Settings starting with execute_
control the execution behaviour. If value is True
, DDL commands of this type will be executed. If value is False
, commands will be "suggested" (dumped for manual execution) instead.
Engine context
Engine collects information about Snowflake connection context during initialization.
You should check which context properties are available in context.py
.
Methods
__init__(connection: SnowflakeConnection, config: SnowDDLConfig, settings: SnowDDLSettings)
Initialize engine with Snowflake connection, config and settings.format(sql, params=None)
Formats SQL query using SnowDDL formatter.query_builder()
Create sand returns new query builder.describe_meta(sql, params=None)
Describes SQL query, compiles it without actually executing and returns information about result columns. If SQL query cannot be compiled, throws an exception.execute_meta(sql, params=None)
Executes SQL query returning metadata information, usuallySHOW
commands.execute_context_ddl(sql, params=None)
Executes DDL command which is used to initialize the current context. It is normally used to create technical role for env prefix feature.execute_safe_ddl(sql, params=None, condition=True)
Executes DDL command which is classified as "safe", usuallyCREATE
. Optionally checks the expression incondition
argument and executes command only if expression isTrue
. Otherwise, it only "suggests" DDL command.execute_unsafe_ddl(sql, params=None, condition=True)
Executes DDL command which is classified as "unsafe", usuallyALTER
,DROP
. Optionally checks the expression incondition
argument and executes command only if expression isTrue
. Otherwise, it only "suggests" DDL command.
Properties
.connection (SnowflakeConnection);
.config (SnowDDLConfig);
.settings (SnowDDLSettings);
.logger (Logger) - pre-initialized logger with name
snowddl.engine
;.executor (ThreadPoolExecutor) - pre-initialized pool executor;
.executed_ddl (list) - list of raw DDL commands which were executed by engine;
{items} (str) - SQL query;
.suggested_ddl (list) - list of raw DDL commands which were suggested for manual execution;
{items} (str) - SQL query;
.context (SnowDDLContext) - pre-initialized context information (version, edition, current warehouse, etc.) extracted from Snowflake account;
.schema_cache (SnowDDLSchemaCache) - pre-initialized cache with databases and schemas, used to reduce the number of metadata queries performed by resolvers;
Last updated