hector_zumaeta
11/14/2019, 11:39 PMtarget-snowflake extractor and was wondering if anyone could help. I have been trying to change the schema that the extractor writes to in the snowflake database. In the configuration fields in both the CLI and the UI only the following fields are available (https://meltano.com/plugins/loaders/snowflake.html#installing-from-the-meltano-cli):
Account
Username
Password
Role
Database
Warehousehector_zumaeta
11/14/2019, 11:39 PMTAP_CSV and is set through an environment variable that the transformer references named MELTANO_ANALYZE_SCHEMA.
I was hoping to be able to set or change environment variables by editing the .env file as referenced here https://meltano.com/plugins/loaders/snowflake.html#installing-from-the-meltano-cli and https://meltano.com/docs/environment-variables.html#anonymous-usage-data. It feels like every project should have this file as part of the init command, but none of the projects that I have created have had an .env file in them yet. I attempted to create an .env file myself in the project directory and set the MELTANO_ANALYZE_SCHEMA var to the right schema name, but it seems to get overwritten and reset at run time by the env variable anyways.hector_zumaeta
11/14/2019, 11:39 PMschema config parameter is pointing to within the current target-snowflake extractor? If not it’s ok I can create a custom one using the current version as a base.
I’m currently on Meltano 1.5.0yannis_roussos
11/15/2019, 9:56 AMtap-csv to load data from CSV files, so the final schema is named by default TAP_CSV (underscore so that it is a valid SQL identifier and all caps when we are working with Snowflake cause it likes caps and makes our life simpler afterwards)
You can change that destination by using the MELTANO_LOAD_SCHEMA environment variable. (the one you used is for the final analytics schema which I'll explain in a while)
So if you want to only use the cli and set everything by using ENV variables, you can create a .env file in your Meltano Project's root with the following:
my_meltano_project/.env
# CSV settings
export TAP_CSV_FILES_DEFINITION="extract/files_def.json"
#Snowflake settings
export SF_ACCOUNT=""
export SF_USER=""
export SF_PASSWORD=""
export SF_ROLE="" # in UPPERCASE
export SF_DATABASE="" # in UPPERCASE
export SF_WAREHOUSE="" # in UPPERCASE
# Global settings for the Target DB/Data Warehouse
export MELTANO_LOAD_SCHEMA="MY_RAW_CSV_DATA"
The MELTANO_ANALYZE_SCHEMA you mentioned is for the next step of the process, the Transformations. This step runs for extractors with pre-bundled transformations (like Gitlab, Salesforce, Google Analytics) or if you have created custom Transformations.
What Meltano does on the Transform step is to run the Transformations over the RAW schema and then store the results to the analytics schema of the Data Warehouse:
(RAW schema) --> Transforms --> (Analytics Schema)
The idea is that we want to keep the RAW data untouched (like a small data lake) and always store the final transformed results in an Analytics schema.
By setting the MELTANO_ANALYZE_SCHEMA environment variable, you can change the Analytics schema from the default analytics one to whatever you may want to use in your Data Warehouse.
.env
...
# Global settings for the Target DB/Data Warehouse
export MELTANO_LOAD_SCHEMA="MY_RAW_CSV_DATA"
export MELTANO_ANALYZE_SCHEMA="MY_ANALYTICS_SCHEMA"
In the case of CSV files, Meltano can not know what you are going to bring in, so we do not include any pre-bundled Transformations and that step has nothing to do even if you ask meltano to write it.
You can add your own Custom Transformations as explained in our Tutorial:
https://meltano.com/tutorials/csv-with-postgres.html
To wrap up this intro with a full description of Meltano's architecture, the Analyze feature inside Meltano UI uses Models to connect to that final Analytics schema and allow the ad-hoc generation of queries and reports.
Not for Advanced Use Cases: We also support the MELTANO_LOAD_SCHEMA_SUFFIX and MELTANO_ANALYZE_SCHEMA_SUFFIX env vars in case you want to dynamically set pipelines that create XXX_test or XXX_production, etc schemas for specific runs (or whatever other suffix you may want, like when you are doing some type of versioning)yannis_roussos
11/15/2019, 10:31 AM.env)
(2) meltano.yml
(3) Configuration settings stored in Meltano's internal db (like the ones you set from inside Meltano UI
(4) Defaults
So if a variable is set in the .env it will always be used by Meltano no matter what you have set in other steps bellow.
Examples:
- Setting MELTANO_LOAD_SCHEMA in the .env will always force Meltano to use that schema when loading data to your Database or Datawarehouse. That's the same if you are using Postgres or Snowflake
- Setting the PG_PASSWORD in the .env will lock the Postgres Loader to use that password even if you set a different one on Meltano UI.yannis_roussos
11/15/2019, 10:36 AM.env file in your Meltano Project's root and set the MELTANO_LOAD_SCHEMA to whatever you want and you'll be able to load the raw data to a schema with a different name
- Set the MELTANO_ANALYZE_SCHEMA env var and you'll change the final analytics schema that Transformations write the final transformed data to whatever you wantyannis_roussos
11/15/2019, 10:45 AMhector_zumaeta
11/15/2019, 4:56 PMyannis_roussos
11/15/2019, 4:58 PM