You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be very useful if we can define re-usable functions.
version: 1default_environment: devproject_id: ee2b1be3-e8f2-4962-a6c8-0af0952c60a5environments:
- name: dev
- name: staging
- name: prodsend_anonymous_usage_stats: falseplugins:
extractors:
- name: tap-mysqlvariant: meltanolabspip_url: git+https://github.com/MeltanoLabs/tap-mysql.gitconfig:
user: rootport: 3306host: 127.0.0.1database: mydatabasefilter_schemas:
- mydatabasessh_tunnel:
enable: falsehost: your_ssh_hostport: 22username: your_ssh_usernameprivate_key: | -----BEGIN OPENSSH PRIVATE KEY----- Your private key content here -----END OPENSSH PRIVATE KEY-----select:
# Core Business Entities
- "mydatabase-companies.*"
- "mydatabase-sites.*"
- "mydatabase-site_details.*"
- "mydatabase-contacts.*"
- "mydatabase-contacts_sites.*"loaders:
- name: target-postgresvariant: meltanolabspip_url: meltanolabs-target-postgresconfig:
host: 127.0.0.1port: 5432user: postgresdbname: postgresdatabase: postgresutilities:
- name: dbt-postgresvariant: dbt-labspip_url: dbt-core dbt-postgres git+https://github.com/meltano/dbt-ext.git@mainconfig:
host: 127.0.0.1port: 5432user: postgresdbname: postgresschema: tap_mysqlmappers:
- name: meltano-map-transformervariant: meltanopip_url: git+https://github.com/MeltanoLabs/meltano-map-transform.gitmappings:
- name: transform_datesconfig:
stream_map_config:
clean_string: | lambda s: s.replace('\0', '') if s else Noneclean_date: | lambda d: d if d and '0000' not in d and '-00' not in d else Noneclean_timestamp: | lambda t: t if t and '0000' not in t and '-00' not in t else Nonestream_maps:
"*": # Apply to all tablescreated_at: clean_timestamp(record['created_at'])updated_at: clean_timestamp(record['updated_at'])mydatabase-contacts:
dob: clean_date(record['dob'])mydatabase-sites:
last_viewed: clean_timestamp(record['last_viewed'])date_moved_in: clean_date(record['date_moved_in'])address_postcode: clean_string(record['address_postcode'])password: clean_string(record['password'])address_1: clean_string(record['address_1'])address_2: clean_string(record['address_2'])address_3: clean_string(record['address_3'])address_county: clean_string(record['address_county'])tag: clean_string(record['tag'])company_name: clean_string(record['company_name'])office_number: clean_string(record['office_number'])office_number_2: clean_string(record['office_number_2'])sector: clean_string(record['sector'])address_town: clean_string(record['address_town'])mydatabase-site_details:
date_incorporated: clean_date(record['date_incorporated'])mydatabase-site_sources:
date_moved_in: clean_date(record['date_moved_in'])jobs:
- name: run_etl_with_transformtasks:
- tap-mysql transform_dates target-postgres
Instead of having to repeat the same bit of code over and over. In reality we actually need to do this instead.
version: 1default_environment: devproject_id: XXXenvironments:
- name: dev
- name: staging
- name: prodsend_anonymous_usage_stats: falseplugins:
extractors:
- name: tap-mysqlvariant: meltanolabspip_url: git+https://github.com/MeltanoLabs/tap-mysql.gitconfig:
user: rootport: 3306host: 127.0.0.1database: mydatabasefilter_schemas:
- mydatabasessh_tunnel:
enable: falsehost: your_ssh_hostport: 22username: your_ssh_usernameprivate_key: | -----BEGIN OPENSSH PRIVATE KEY----- Your private key content here -----END OPENSSH PRIVATE KEY-----select:
# Core Business Entities
- "mydatabase-companies.*"
- "mydatabase-sites.*"
- "mydatabase-site_details.*"
- "mydatabase-contacts.*"
- "mydatabase-contacts_sites.*"loaders:
- name: target-postgresvariant: meltanolabspip_url: meltanolabs-target-postgresconfig:
host: 127.0.0.1port: 5432user: postgresdbname: postgresdatabase: postgresutilities:
- name: dbt-postgresvariant: dbt-labspip_url: dbt-core dbt-postgres git+https://github.com/meltano/dbt-ext.git@mainconfig:
host: 127.0.0.1port: 5432user: postgresdbname: postgresschema: tap_mysqlmappers:
- name: meltano-map-transformervariant: meltanopip_url: git+https://github.com/MeltanoLabs/meltano-map-transform.gitmappings:
- name: transform_datesconfig:
stream_maps:
"*": # Apply to all tablescreated_at:
record['created_at'] if record.get('created_at') and '0000'not in record['created_at'] and '-00' not in record['created_at'] else Noneupdated_at:
record['updated_at'] if record.get('updated_at') and '0000'not in record['updated_at'] and '-00' not in record['updated_at'] else Nonemydatabase-contacts:
dob:
record['dob'] if record.get('dob') and '0000' not in record['dob']and '-00' not in record['dob'] else Nonemydatabase-sites:
last_viewed:
record['last_viewed'] if record.get('last_viewed') and '0000'not in record['last_viewed'] and '-00' not in record['last_viewed'] else Nonedate_moved_in:
record['date_moved_in'] if record.get('date_moved_in') and'0000'not in record['date_moved_in'] and '-00' not in record['date_moved_in'] else Noneaddress_postcode: record['address_postcode'].replace('\0', '') if record.get('address_postcode') else Nonepassword: record['password'].replace('\0', '') if record.get('password') else Noneaddress_1: record['address_1'].replace('\0', '') if record.get('address_1') else Noneaddress_2: record['address_2'].replace('\0', '') if record.get('address_2')else Noneaddress_3: record['address_3'].replace('\0', '') if record.get('address_3')else Noneaddress_county: record['address_county'].replace('\0', '') if record.get('address_county')else Nonetag: record['tag'].replace('\0', '') if record.get('tag') else Nonecompany_name: record['company_name'].replace('\0', '') if record.get('company_name') else Noneoffice_number: record['office_number'].replace('\0', '') if record.get('office_number') else Noneoffice_number_2: record['office_number_2'].replace('\0', '') if record.get('office_number_2') else Nonesector: record['sector'].replace('\0', '') if record.get('sector') else Noneaddress_town: record['address_town'].replace('\0', '') if record.get('address_town') else Nonemydatabase-site_details:
date_incorporated:
record['date_incorporated'] if record.get('date_incorporated')and '0000' not in record['date_incorporated'] and '-00' not in record['date_incorporated'] else Nonemydatabase-site_sources:
date_moved_in:
record['date_moved_in'] if record.get('date_moved_in') and'0000'not in record['date_moved_in'] and '-00' not in record['date_moved_in'] else Nonejobs:
- name: run_etl_with_transformtasks:
- tap-mysql transform_dates target-postgres
The text was updated successfully, but these errors were encountered:
We could support a new key (e.g. user_functions) under stream_map_config, then parse and cache each function definition and pass it to the simpleeval context.
It would be very useful if we can define re-usable functions.
Instead of having to repeat the same bit of code over and over. In reality we actually need to do this instead.
The text was updated successfully, but these errors were encountered: