Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade sqlfluff to 3.2.x #660

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self) -> None:
install_requires=[
"sqlparse==0.5.0",
"networkx>=2.4",
"sqlfluff==3.0.5",
"sqlfluff~=3.2.5",
"sqlalchemy>=2.0.0",
],
entry_points={"console_scripts": ["sqllineage = sqllineage.cli:main"]},
Expand Down
3 changes: 2 additions & 1 deletion sqllineage/core/parser/sqlfluff/extractors/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def _handle_swap_partition(
function.first_non_whitespace_segment_raw_upper
== "SWAP_PARTITIONS_BETWEEN_TABLES"
):
if bracketed := function.get_child("bracketed"):
if function_contents := function.get_child("function_contents"):
bracketed = function_contents.segments[0]
expressions = bracketed.get_children("expression")
holder.add_read(
SqlFluffTable(
Expand Down
4 changes: 3 additions & 1 deletion sqllineage/core/parser/sqlfluff/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _extract_source_columns(segment: BaseSegment) -> List[ColumnQualifierTuple]:
sub_segments = list_child_segments(segment)
col_list = []
for sub_segment in sub_segments:
if sub_segment.type == "bracketed":
if sub_segment.type in ("bracketed", "function_contents"):
if is_subquery(sub_segment):
col_list += SqlFluffColumn._get_column_from_subquery(
sub_segment
Expand Down Expand Up @@ -206,6 +206,8 @@ def _get_column_from_parenthesis(
# windows function has an extra layer, get rid of it so that it can be handled as regular functions
if window_specification := sub_segment.get_child("window_specification"):
sub_segment = window_specification
elif sub_segment.type == "function_contents":
sub_segment = sub_segment.segments[0]
col, _ = SqlFluffColumn._get_column_and_alias(sub_segment, False)
return col if col else []

Expand Down