Skip to content

Commit f8c8c4f

Browse files
fix: Expand env vars in stream_map_config (#421)
## Related - meltano/meltano#7151 - meltano/meltano#9626
1 parent 0f94e3b commit f8c8c4f

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ jobs:
103103
select * from cust
104104
union
105105
select * from empl
106+
- tap: tap-csv--multi
107+
mapping: expand_env_vars
108+
output_db: tap_csv__multi.db
109+
query: |
110+
with
111+
cust_with_extra as (select *, 'CUSTOMER' as type from customers limit 10),
112+
empl_with_extra as (select *, 'EMPLOYEE' as type from employees limit 10)
113+
114+
select * from cust_with_extra
115+
union
116+
select * from empl_with_extra
106117
steps:
107118
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
108119

@@ -126,6 +137,9 @@ jobs:
126137
meltano --version
127138
128139
- name: Run
140+
env:
141+
MELTANO_RUN_ID: C95FD852-6766-4D11-A484-6CA858AA6939
142+
ELT_RUN_STARTED_AT: "2025-01-01T00:00:00Z"
129143
run: |
130144
meltano run --install ${{ matrix.tap }} ${{ matrix.mapping }} target-sqlite
131145

meltano.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ plugins:
4646
settings:
4747
- name: stream_maps
4848
kind: object
49+
- name: stream_maps_config
50+
kind: object
4951
mappings:
5052
- name: hash_email
5153
config:
@@ -129,6 +131,17 @@ plugins:
129131
"*":
130132
name: first_name
131133
first_name: __NULL__
134+
# Expand environment variables
135+
- name: expand_env_vars
136+
config:
137+
stream_maps:
138+
"*":
139+
_extract__run_id: config['_extract__run_id']
140+
# _extract__run_id: $MELTANO_RUN_ID
141+
_extract__run_started_at: config['_extract__run_started_at']
142+
stream_map_config:
143+
_extract__run_id: $MELTANO_RUN_ID # tried with {}s, quotes, etc etc etc...
144+
_extract__run_started_at: $ELT_RUN_STARTED_AT
132145
environments:
133146
- name: dev
134147
config:

meltano_map_transform/mapper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class StreamTransform(InlineMapper):
4747
required=True,
4848
description="Stream maps",
4949
),
50+
th.Property(
51+
"stream_map_config",
52+
th.ObjectType(),
53+
title="User Stream Map Configuration",
54+
description="User-defined config values to be used within map expressions.",
55+
),
5056
th.Property(
5157
"flattening_enabled",
5258
th.BooleanType(),

plugins/extractors/tap-csv--meltanolabs.lock

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737
"description": "Project-relative path to JSON file holding array of objects as described under [Files](#files) - with `entity`, `path`, `keys`, and other optional keys:\n\n```json\n[\n {\n \"entity\": \"<entity>\",\n \"path\": \"<path>\",\n \"keys\": [\"<key>\"],\n },\n // ...\n]\n```\n",
3838
"placeholder": "Ex. files-def.json"
3939
},
40+
{
41+
"name": "faker_config.locale",
42+
"kind": "array",
43+
"label": "Faker Locale",
44+
"description": "One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization"
45+
},
46+
{
47+
"name": "faker_config.seed",
48+
"kind": "string",
49+
"label": "Faker Seed",
50+
"description": "Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator"
51+
},
4052
{
4153
"name": "files",
4254
"kind": "array",
@@ -46,19 +58,19 @@
4658
{
4759
"name": "flattening_enabled",
4860
"kind": "boolean",
49-
"label": "Flattening Enabled",
61+
"label": "Enable Schema Flattening",
5062
"description": "'True' to enable schema flattening and automatically expand nested properties."
5163
},
5264
{
5365
"name": "flattening_max_depth",
5466
"kind": "integer",
55-
"label": "Flattening Max Depth",
67+
"label": "Max Flattening Depth",
5668
"description": "The max depth to flatten schemas."
5769
},
5870
{
5971
"name": "stream_map_config",
6072
"kind": "object",
61-
"label": "Stream Map Config",
73+
"label": "User Stream Map Configuration",
6274
"description": "User-defined config values to be used within map expressions."
6375
},
6476
{

plugins/mappers/meltano-map-transformer--meltano.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"label": "Meltano Map Transformer",
77
"docs": "https://hub.meltano.com/mappers/meltano-map-transformer--meltano",
88
"repo": "https://github.com/MeltanoLabs/meltano-map-transform",
9-
"pip_url": "git+https://github.com/MeltanoLabs/meltano-map-transform.git",
9+
"pip_url": "meltano-map-transform",
1010
"executable": "meltano-map-transform",
1111
"description": "A map transformer which implements the Stream Maps capability from Meltano's tap and target SDK.",
1212
"logo_url": "https://hub.meltano.com/assets/logos/mappers/meltano.png",

0 commit comments

Comments
 (0)