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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ lint:
poetry run flake8 sql_metadata
poetry run pylint sql_metadata

format:
poetry run black .

publish:
# run git tag -a v0.0.0 before running make publish
poetry build
Expand Down
14 changes: 10 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sql_metadata/keywords_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"INTO",
"UPDATE",
"TABLE",
"IFNOTEXISTS",
}

# next statement beginning after with statement
Expand Down
1 change: 1 addition & 0 deletions sql_metadata/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ def _determine_last_relevant_keyword(self, token: SQLToken, last_keyword: str):
and self._open_parentheses[-1].is_partition_clause_start
)
and not (token.normalized == "USING" and last_keyword == "SELECT")
and not (token.normalized == "IFNOTEXISTS")
):
last_keyword = token.normalized
return last_keyword
Expand Down
5 changes: 3 additions & 2 deletions sql_metadata/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ def is_potential_table_name(self) -> bool:
(self.is_name or self.is_keyword)
and self.last_keyword_normalized in TABLE_ADJUSTMENT_KEYWORDS
and self.previous_token.normalized not in ["AS", "WITH"]
and self.normalized not in ["AS", "SELECT", "IF", "SET", "WITH"]
and self.normalized
not in ["AS", "SELECT", "IF", "SET", "WITH", "IFNOTEXISTS"]
)

@property
Expand All @@ -288,7 +289,7 @@ def is_alias_of_table_or_alias_of_subquery(self) -> bool:
is_alias_without_as = (
self.previous_token.normalized != self.last_keyword_normalized
and not self.previous_token.is_punctuation
and not self.previous_token.normalized == "EXISTS"
and not self.previous_token.normalized == "IFNOTEXISTS"
)
return is_alias_without_as or self.previous_token.is_right_parenthesis

Expand Down