SnowDDL
Search…
πŸ”΄
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) Format SQL query using SnowDDL formatter.
  • query_builder() Create and return new query builder.
  • describe_meta(sql, params=None) Describe SQL query, compile it without actually executing and return information about result columns. If SQL query cannot be compiled, throws an exception.
  • execute_meta(sql, params=None) Execute SQL query returning metadata information, usually SHOW commands.
  • execute_context_ddl(sql, params=None) Execute DDL command which is used to initialize the current context, usually it is used to create technical role for env prefix feature.
  • execute_safe_ddl(sql, params=None, condition=True) Execute DDL command which is classified as "safe", usually CREATE. Optionally check the expression in condition argument if it was passed.
  • execute_unsafe_ddl(sql, params=None, condition=True) Execute DDL command which is classified as "unsafe", usually ALTER, DROP. Optionally check the expression in condition argument if it was passed.

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;
Copy link
On this page
Engine settings
Engine context
Methods
Properties