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

F/support table filter expr #21

Open
wants to merge 3 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
8 changes: 8 additions & 0 deletions tap_dynamodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def do_sync(config, catalog, state):
key_properties = metadata.get(mdata, (), 'table-key-properties')
singer.write_schema(stream_name, stream['schema'], key_properties)

filter_expression = metadata.get(mdata, (), 'FilterExpression')
filter_value = metadata.get(mdata, (), 'ExpressionAttributeValues')
scan_params = {}
if filter_expression and filter_value:
scan_params = { 'FilterExpression': filter_expression, 'ExpressionAttributeValues': json.loads(filter_value) }
config = { **config, **scan_params }
LOGGER.info("Applying scan_params: %s for stream: %s", str(scan_params), stream_name)

LOGGER.info("%s: Starting sync", stream_name)
counts[stream_name] = sync_stream(config, state, stream)
sync_times[stream_name] = time.time() - start_time
Expand Down
3 changes: 3 additions & 0 deletions tap_dynamodb/sync_strategies/full_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def scan_table(table_name, projection, last_evaluated_key, config):
'TableName': table_name,
'Limit': 1000
}
if 'FilterExpression' in config:
scan_params['FilterExpression'] = config['FilterExpression']
scan_params['ExpressionAttributeValues'] = config['ExpressionAttributeValues']

if projection is not None:
scan_params['ProjectionExpression'] = projection
Expand Down