Fix lineage to support 'merge into' queries starting with comments (#8355)

This commit is contained in:
Nahuel 2022-10-25 19:29:59 +02:00 committed by GitHub
parent e9ebb4dd75
commit 1583adee29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -60,7 +60,7 @@ def clean_raw_query(raw_query: str) -> str:
replace_by=" ",
)
if insensitive_match(clean_query, "merge into .*when matched.*"):
if insensitive_match(clean_query, ".*merge into .*when matched.*"):
clean_query = insensitive_replace(
raw_str=clean_query,
to_replace="when matched.*", # merge into queries specific

View File

@ -166,10 +166,10 @@ class QueryParserTests(TestCase):
Validate query cleaning logic
"""
query = """
merge into table_1 using (select a, b from table_2) when matched update set t.a = 'value'
/* comment */ merge into table_1 using (select a, b from table_2) when matched update set t.a = 'value'
when not matched then insert (table_1.a, table_2.b) values ('value1', 'value2')
"""
self.assertEqual(
clean_raw_query(query),
"merge into table_1 using (select a, b from table_2)",
"/* comment */ merge into table_1 using (select a, b from table_2)",
)