Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: stream_maps "*" doesn't work. Appears to do nothing at all #2602

Open
1 task done
gruckion opened this issue Aug 13, 2024 · 3 comments
Open
1 task done

bug: stream_maps "*" doesn't work. Appears to do nothing at all #2602

gruckion opened this issue Aug 13, 2024 · 3 comments

Comments

@gruckion
Copy link

Singer SDK Version

How do I find this?

Is this a regression?

  • Yes

Python Version

3.12

Bug scope

Mapping (stream maps, flattening, etc.)

Operating System

Mac OSX

Description

Expected: As per the documentation to be able to rename a field. Using "*" in the loaders stream_maps for meltanolabs-target-postgres.

https://sdk.meltano.com/en/latest/stream_maps.html#applying-a-mapping-across-two-or-more-streams

Code

I tried to apply a change based on the docs. But I do not see acc_num in the outputted model 🤷 


        stream_maps:
          "*":
            acc_num: account_number
            account_number: __NULL__


What I actually want is.

```yaml
stream_maps:
  "*":
    name: first_name
    first_name: __NULL__
  loaders:
    - name: target-postgres
      variant: meltanolabs
      pip_url: meltanolabs-target-postgres
      config:
        host: 127.0.0.1
        port: 5432
        user: postgres
        dbname: postgres
        database: postgres
        stream_maps:
          mydatabase-bank_accounts:
            created_at:
              record['created_at'] if record.get('created_at') and '0000'
              not in record['created_at'] and '-00' not in record['created_at'] else
              '1970-01-01 00:00:00'
            updated_at:
              record['updated_at'] if record.get('updated_at') and '0000'
              not in record['updated_at'] and '-00' not in record['updated_at'] else
              '1970-01-01 00:00:00'

But this doesn't work. I'm doing a tap mysql -> postgres. The source mysql db has a load of invalid postgres date / timestamps that I need to accomidate.

Disgustingly I have to put

        stream_maps:
          mydatabase-my_table_name:
            created_at:
              record['created_at'] if record.get('created_at') and '0000'
              not in record['created_at'] and '-00' not in record['created_at'] else
              '1970-01-01 00:00:00'
            updated_at:
              record['updated_at'] if record.get('updated_at') and '0000'
              not in record['updated_at'] and '-00' not in record['updated_at'] else
              '1970-01-01 00:00:00'

Manually for each and every table 😢 .

@gruckion gruckion added kind/Bug Something isn't working valuestream/SDK labels Aug 13, 2024
@edgarrmondragon
Copy link
Collaborator

@gruckion See my comment in #1605 (comment). I can confirm the glob syntax is working .

@gruckion
Copy link
Author

gruckion commented Sep 9, 2024

@gruckion See my comment in #1605 (comment). I can confirm the glob syntax is working .

I see, your using plugin. That works, but the stream maps that's built in doesn't work.

@edgarrmondragon
Copy link
Collaborator

That works, but the stream maps that's built in doesn't work.

Hey @gruckion. I don't understand the distinction you're making. In the linked comment, I'm using stream_maps as part of the target-postgres config, just like in the meltano.yml example you shared.

Am I missing something? In which situations does the glob syntax not work? Can you share an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants