Skip to main content
Version: 1.33.0 (latest)

dlt.destinations.impl.snowflake.utils

CONNECTION_FILE_PATH_PARAMS​

Connection parameters that hold a file path

gen_copy_sql​

def gen_copy_sql(
file_url: str,
qualified_table_name: str,
loader_file_format: TLoaderFileFormat,
is_case_sensitive: bool,
stage_name: Optional[str] = None,
stage_bucket_url: Optional[str] = None,
local_stage_file_path: Optional[str] = None,
staging_credentials: Optional[CredentialsConfiguration] = None,
csv_format: Optional[CsvFormatConfiguration] = None,
use_vectorized_scanner: Optional[bool] = False) -> str

View source on GitHub

Generates a Snowflake COPY command to load data from a file.

Arguments:

  • use_vectorized_scanner - Whether to use the vectorized scanner in COPY INTO
  • file_url - URL of the file to load
  • qualified_table_name - Fully qualified name of the target table
  • loader_file_format - Format of the source file (jsonl, parquet, csv)
  • is_case_sensitive - Whether column matching should be case-sensitive
  • stage_name - Optional name of a predefined Snowflake stage
  • stage_bucket_url - Optional URL of the bucket containing the file
  • local_stage_file_path - Path to use for local files
  • staging_credentials - Optional credentials for accessing cloud storage
  • csv_format - Optional configuration for CSV format

Returns:

A SQL string containing the COPY command

snowflake_session_token_available​

def snowflake_session_token_available() -> bool

View source on GitHub

Whether Snowflake-provided OAuth token is available in environment.

Reference: https://docs.snowflake.com/en/developer-guide/snowpark-container-services/additional-considerations-services-jobs#connecting-with-a-snowflake-provided-oauth-token

read_default_snowflake_connection_name​

def read_default_snowflake_connection_name() -> str

View source on GitHub

Reads the default connection name of the connector from SNOWFLAKE_DEFAULT_CONNECTION_NAME or config.toml, else returns default.

list_snowflake_connections​

def list_snowflake_connections() -> List[str]

View source on GitHub

Names of the connections that the connector finds in connections.toml or config.toml.

get_snowflake_default_connection_name​

def get_snowflake_default_connection_name() -> Optional[str]

View source on GitHub

Default connection name of the connector, None when no such connection is defined or the connector is not installed.

get_snowflake_container_connection_name​

def get_snowflake_container_connection_name() -> Optional[str]

View source on GitHub

Name of the connection that Snowpark Container Services mounts into a container (sessionTokenConfig.mountConnectionConfig), None outside such a container.

read_snowflake_connection_params​

def read_snowflake_connection_params(connection_name: str) -> Dict[str, Any]

View source on GitHub

Parameters of connection connection_name with ~ expanded in its file paths.

get_snowflake_connection_file_paths​

def get_snowflake_connection_file_paths(
connection_name: str) -> Dict[str, str]

View source on GitHub

Returns the file paths of connection connection_name with ~ expanded.

The connector does not expand ~, so dlt passes these paths to connect together with the connection name.

read_snowflake_session_token​

def read_snowflake_session_token() -> str

View source on GitHub

Read the session token supplied automatically by Snowflake. These tokens are short lived and should always be read right before creating any new connection.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.