-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DH-5766/adding the validation to raise exception for queries without …
…schema in multiple schema setting
- Loading branch information
1 parent
b24d9c8
commit b4f57c4
Showing
2 changed files
with
24 additions
and
0 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
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,11 @@ | ||
from sql_metadata import Parser | ||
|
||
|
||
def extract_the_schemas_from_sql(sql): | ||
table_names = Parser(sql).tables | ||
schemas = [] | ||
for table_name in table_names: | ||
if "." in table_name: | ||
schema = table_name.split(".")[0] | ||
schemas.append(schema.strip()) | ||
return schemas |