<#1532 feat: environment variables inside stream m...
# meltano-repo-activity
g
#1532 feat: environment variables inside stream maps Issue created by sbalnojan Feature scope Configuration (settings parsing, validation, etc.) Description Feature: I want to use environment variables inside stream maps, and I am unable to find a way to get them through. One example use case is using a predefined "run_id=date + time today":
Copy code
- name: add-run-no
      config:
        stream_maps:
          customers:
            run_id: config['run_id']
            __alias__: customers_v8
        stream_map_config:
          run_id: ${RUN_ID} # export RUN_ID=$(printf '%(%Y-%m-%d-%H-%M-%S)T\n' -1);
I'd then run the above with export RUN_ID=$(printf '%(%Y-%m-%d-%H-%M-%S)T\n' -1);
meltano run tap-csv add-run-no target-sqlite3
. The output here is:
Copy code
@sbalnojan ➜ /workspaces/meltano-map-transform/examples (main) $ sqlite3 -markdown output/tap_csv.db 'select * from customers_v8 limit 20'
|           email            | env_run_id | first_name | id |   ip_address    | last_name  |  run_id   |        __loaded_at         |
|----------------------------|------------|------------|----|-----------------|------------|-----------|----------------------------|
| ebook0@twitter.com         |            | Ethe       | 1  | 67.61.243.220   | Book       | ${RUN_ID} | 2023-03-27 11:56:41.716255 |
| mtire1@vkontakte.ru        |            | Myranda    | 2  | 151.194.73.229  | Tire       | ${RUN_ID} | 2023-03-27 11:56:41.716444 |
| rdorian2@twitpic.com       |            | Remus      | 3  | 204.220.73.121  | Dorian     | ${RUN_ID} | 2023-03-27 11:56:41.716584 |
I've tried one workaround:
Copy code
- name: add-run-no
      config:
        stream_maps:
          customers:
            #768 run_id: config['run_id']
            env_run_id: os.getenv('RUN_ID') 
            __alias__: customers_v8
        stream_map_config:
          run_id: ${RUN_ID} # export RUN_ID=$(printf '%(%Y-%m-%d-%H-%M-%S)T\n' -1);
. That code with the above run command gives me the (obv.) error:
singer_sdk.helpers._simpleeval.NameNotDefined: 'os' is not defined for expression 'os.getenv('RUN_ID')'
as the os package isn't accessible via simpleeval. @aaronsteers @Edgar Ramírez (Arch.dev). meltano/sdk