Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Keep non-discoverable metadata from the nodes #88

Open
wants to merge 1 commit 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
6 changes: 6 additions & 0 deletions tap_postgres/stream_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def refresh_streams_schema(conn_config: Dict, streams: List[Dict]):
if not metadatum['breadcrumb']:
meta.update(new_discovery[stream['tap_stream_id']]['metadata'][idx_met]['metadata'])
new_discovery[stream['tap_stream_id']]['metadata'][idx_met]['metadata'] = meta
elif metadatum['breadcrumb'] in md_map:
# takes discoverable node's metadata from new_discover
# and keeps remaining metadata from the original node (like 'selected')
node_md_map = md_map.get(metadatum['breadcrumb'])
node_md_map.update(metadatum['metadata'])
new_discovery[stream['tap_stream_id']]['metadata'][idx_met]['metadata'] = node_md_map

# 2nd step: now copy all the metadata from the updated new discovery to the original stream
streams[idx]['metadata'] = copy.deepcopy(new_discovery[stream['tap_stream_id']]['metadata'])
Expand Down
14 changes: 12 additions & 2 deletions tests/test_streams_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def setUp(self):
{"name": '"character-varying_name"', "type": "character varying"},
{"name": '"varchar-name"', "type": "varchar(28)"},
{"name": 'char_name', "type": "char(10)"},
{"name": '"text-name"', "type": "text"}],
{"name": '"text-name"', "type": "text"},
{"name": '"column_to_exclude-name"', "type": "text"}],
"name": self.table_name}

ensure_test_table(table_spec)
Expand All @@ -51,6 +52,10 @@ def test_refresh_streams_schema(self):
'table-key-properties': ['some_id'],
'row-count': 1000,
}
},
{
'breadcrumb': ['properties', 'column_to_exclude-name'],
'metadata': {'selected': False}
}
]
}
Expand All @@ -75,6 +80,10 @@ def test_refresh_streams_schema(self):
('properties', 'character-varying_name'): {'inclusion': 'available',
'sql-datatype': 'character varying',
'selected-by-default': True},
('properties', 'column_to_exclude-name'): {'inclusion': 'available',
'selected': False,
'selected-by-default': True,
'sql-datatype': 'text'},
('properties', 'id'): {'inclusion': 'automatic',
'sql-datatype': 'integer',
'selected-by-default': True},
Expand All @@ -94,6 +103,7 @@ def test_refresh_streams_schema(self):
'character-varying_name': {'type': ['null', 'string']},
'varchar-name': {'type': ['null', 'string'], 'maxLength': 28},
'char_name': {'type': ['null', 'string'], 'maxLength': 10},
'text-name': {'type': ['null', 'string']}},
'text-name': {'type': ['null', 'string']},
'column_to_exclude-name': {'type': ['null', 'string']}},
'type': 'object',
'definitions': BASE_RECURSIVE_SCHEMAS}, streams[0].get('schema'))