Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ def _parse_yaml_if_possible(value: Any) -> Any:
return yaml.safe_load(value)
except ParserError: # "{{ record[0] in ['cohortActiveUsers'] }}" # not valid YAML
return value
except ScannerError as e: # "%Y-%m-%d' # not valid yaml
except ScannerError as e: # "%Y-%m-%d" or strings with tabs - not valid YAML
if "expected alphabetic or numeric character, but found '%'" in str(e):
return value
if "found character '\\t' that cannot start any token" in str(e):
return value
raise e
Comment thread
tolik0 marked this conversation as resolved.
return value
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ def to_configured_catalog(
}
)

# Manifest with component definition with value containing tab characters
# which would cause YAML ScannerError (tabs cannot start tokens in YAML)
_MANIFEST_WITH_TAB_SCANNER_ERROR = deepcopy(_MANIFEST)
_MANIFEST_WITH_TAB_SCANNER_ERROR["dynamic_streams"][0]["components_resolver"][
"components_mapping"
].append(
{
"type": "ComponentMappingDefinition",
"create_or_update": True,
"field_path": ["retriever", "requester", "$parameters", "custom_query"],
"value": "SELECT\n\tcampaign.name,\n\tcampaign.id\nFROM campaign", # Contains tab characters
}
)


@pytest.mark.parametrize(
"manifest, config, expected_exception, expected_stream_names",
Expand All @@ -173,8 +187,15 @@ def to_configured_catalog(
),
(_MANIFEST_WITH_STREAM_CONFIGS_LIST, _CONFIG, None, ["item_1", "item_2", "default_item"]),
(_MANIFEST_WITH_SCANNER_ERROR, _CONFIG, None, ["item_1", "item_2", "default_item"]),
(_MANIFEST_WITH_TAB_SCANNER_ERROR, _CONFIG, None, ["item_1", "item_2", "default_item"]),
],
ids=[
"no_duplicates",
"duplicates",
"stream_configs_list",
"scanner_error",
"tab_scanner_error",
],
ids=["no_duplicates", "duplicates", "stream_configs_list", "scanner_error"],
)
def test_dynamic_streams_read_with_config_components_resolver(
manifest, config, expected_exception, expected_stream_names
Expand Down
Loading