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

Bypassing the stream_is_selected If Operation #27

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
"bucket": "my-bucket",
"external_id": "my_optional_secret_external_id",
"tables": "[{\"search_prefix\":\"exports\",\"search_pattern\":\"my_table\\\\/.*\\\\.csv\",\"table_name\":\"my_table\",\"key_properties\":\"id\",\"date_overrides\":\"created_at\",\"delimiter\":\",\"}]",
"skip_stream_is_selected": true
}
15 changes: 10 additions & 5 deletions tap_s3_csv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ def stream_is_selected(mdata):
return mdata.get((), {}).get('selected', False)


def do_sync(config, catalog, state):
def do_sync(config, catalog, state, skip_stream_is_selected=False):
LOGGER.info('Starting sync.')

for stream in catalog['streams']:
stream_name = stream['tap_stream_id']
mdata = metadata.to_map(stream['metadata'])
table_spec = next(s for s in config['tables'] if s['table_name'] == stream_name)
if not stream_is_selected(mdata):
LOGGER.info("%s: Skipping - not selected", stream_name)
continue
if not skip_stream_is_selected:
if not stream_is_selected(mdata):
LOGGER.info("%s: Skipping - not selected", stream_name)
continue

singer.write_state(state)
key_properties = metadata.get(mdata, (), 'table-key-properties')
Expand Down Expand Up @@ -84,7 +85,11 @@ def main():
if args.discover:
do_discover(args.config)
elif args.properties:
do_sync(config, args.properties, args.state)
skip_stream_validation = str(config.get("skip_stream_is_selected")).lower() == "true"
if skip_stream_validation:
do_sync(config, args.properties, args.state, skip_stream_is_selected=skip_stream_validation)
else:
do_sync(config, args.properties, args.state)


if __name__ == '__main__':
Expand Down