Snowflake
Connection parameters in YAML configuration file
Note
This article refers to BaseModel accessed via Docker container. Please refer to Snowflake Native App section if you are using BaseModel as SF GUI application.
Various data sources are specified in the YAML file used by the pretrain
function and configured by the entries in data_location
section. Below is an example code for Snowflake that should be adapted to your configuration.
data_location:
database_type: snowflake
connection_params:
user: username,
password: strongpassword123,
account: xy12345.west-europe.azure,
warehouse: warehouse_name,
database: example_db,
schema: example_schema,
role: relevant_role,
table_name: some_table
Parameters |
---|
- database_type : str, required
No default value.
Information about the database type or source file. All data tables should be stored in the same type.
Set to:snowflake
.
- connection_params : dict, required
Configures the connection to the database.
For Snowflake its keyword arguments are:
- user : str, required
No default value.
Specifies the login name of the user for the connection. Environment variable can be called.
Examples:"firstnamelastname"
,"${SNOWFLAKE_USER}"
- password : str, required
No default value.
Specifies the password for the specified user. Environment variable can be called.
Examples:"strongpassword123"
,"${SNOWFLAKE_PASSWORD}"
- account : str, required
No default value.
Specifies the account identifier of your organisation. Environment variable can be called.
Examples:"ab12345.eu-central-2"
,"${SNOWFLAKE_ACCOUNT}"
- warehouse : str, required
No default value.
Specifies the virtual warehouse to use once connected, or specifies an empty string. The specified warehouse should be an existing warehouse for which the specified default role has privileges. Environment variable can be called.
Examples:"warehouse_name"
,"${SNOWFLAKE_WAREHOUSE}"
- database : str, required
No default value.
Specifies the default database to use once connected, or specifies an empty string. The specified database should be an existing database for which the specified default role has privileges.
Examples:"example_db"
- schema : str, required
No default value.
Specifies the default schema to use for the specified database once connected, or specifies an empty string. The specified schema should be an existing schema for which the specified default role has privileges.
Examples:"public"
- role : str, optional:
Default: "PUBLIC"
Specifies the role to use. Environment variable can be called.
Examples="DB_ADMIN"
,"${SNOWFLAKE_ROLE}"
- user : str, required
- table_name (str)
Specifies the table to use to create features. Example:customers
.
The connection_params
should be set separately in each data_location
block, for each data source.
Note
For security reasons, avoid providing credentials and other Snowflake connection variables directly in the code; instead, set them as environment variables and call as such, an in the example below.
Example |
---|
The following example demonstrates the connection to Snowflake in the context of a simple configuration with two data sources.
data_sources:
-type: main_entity_attribute
main_entity_column: UserID
name: customers
data_location:
database_type: snowflake
connection_params:
user: ${SNOWFLAKE_USER},
password: ${SNOWFLAKE_PASSWORD},
account: ${SNOWFLAKE_ACCOUNT},
warehouse: ${SNOWFLAKE_WAREHOUSE},
database: EXAMPLE_DB,
schema: EXAMPLE_SCHEMA,
role: ACCOUNT_ADMIN
table_name: customers
disallowed_columns: [CreatedAt]
-type: event
main_entity_column: UserID
name: purchases
date_column: Timestamp
data_location:
database_type: snowflake
connection_params:
user: ${SNOWFLAKE_USER},
password: ${SNOWFLAKE_PASSWORD},
account: ${SNOWFLAKE_ACCOUNT},
warehouse: ${SNOWFLAKE_WAREHOUSE},
database: EXAMPLE_DB,
schema: EXAMPLE_SCHEMA,
role: ACCOUNT_ADMIN
table_name: purchases
where_condition: "Timestamp >= today() - 365"
sql_lambdas:
- alias: price_float
expression: "TO_DOUBLE(price)"
For more details about Python connector to Snowflake please refer to the Snowflake documentation.
Note
The detailed description of optional fields such as
disallowed_columns
,where_condition
,sql_lambda
, and many others is provided here
Updated 2 months ago