slingdata-io / sling-cli

Sling is a CLI tool that extracts data from a source storage/database and loads it in a target storage/database.
https://docs.slingdata.io
GNU General Public License v3.0
416 stars 30 forks source link

Parameterize connection settings in replication.yaml. #396

Open dvdrndlph opened 5 days ago

dvdrndlph commented 5 days ago

Issue Description

source: MY_MYSQL
target: MY_BIGQUERY

defaults:
  mode: incremental
  object: {target_schema}.{stream_schema}_{stream_table}
  primary_key: [id]

But {target_schema} does not get populated with the schema name from env.yaml.

It is inconvenient to have to hard-code the target schema.

As above.

fatal:
--- proc.go:271 main ---
--- sling_cli.go:458 main ---
--- sling_cli.go:494 cliInit ---
--- cli.go:286 CliProcess ---
--- sling_run.go:200 processRun ---
~ failure running replication (see docs @ https://docs.slingdata.io/sling-cli)
--- sling_run.go:438 runReplication ---
~ Error parsing replication config
--- replication.go:767 LoadReplicationConfigFromFile ---
~ Error parsing replication config
--- replication.go:779 LoadReplicationConfig ---
~ Error parsing yaml content
--- replication.go:585 UnmarshalReplication ---
yaml: line 3: mapping values are not allowed in this context

Many thanks.

flarco commented 1 day ago

hey @dvdrndlph in your connection entry in the env.yaml, are you specifying a schema key?

dvdrndlph commented 1 day ago

Yes, here is the stanza for the target connection:

  ORABOODLE:
    type: oracle
    host: db-test.foo.uic.edu
    user: TST_CDW
    port: 1527
    service_name: OLD.foo.uic.edu
    schema: TST_CDW
    password: ***
dvdrndlph commented 1 day ago

My env.yaml starts like this:

source: CDW_MSSQL
target: ORABOODLE

defaults:
  mode: incremental
  object: {target_schema}.{stream_table}
  update_key: _LastUpdatedInstant

streams:
  AddressHistoryFact:
    primary_key: AddressHistoryKey
.
.
.

I have to hard code TST_CDW in lieu of {target_schema} to run the replication.