forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ingest/bigquery): escape special characters for table descriptions (
- Loading branch information
1 parent
5bee25f
commit 782d33d
Showing
4 changed files
with
98 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/bigquery_helper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Optional | ||
|
||
|
||
def unquote_and_decode_unicode_escape_seq( | ||
string: str, | ||
leading_quote: str = '"', | ||
trailing_quote: Optional[str] = None, | ||
) -> str: | ||
""" | ||
If string starts and ends with a quote, unquote it and decode Unicode escape sequences | ||
""" | ||
trailing_quote = trailing_quote if trailing_quote else leading_quote | ||
|
||
if string.startswith(leading_quote) and string.endswith(trailing_quote): | ||
string = string[1:-1] | ||
|
||
cleaned_string = string.encode().decode("unicode-escape") | ||
|
||
return cleaned_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters