Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
joocer committed Apr 2, 2023
1 parent 1926543 commit a8be8da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions opteryx/components/logical_planner/custom_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class RelationDescription:
cache: Any = None


def extract_show_filter(ast):
def extract_show_filter(ast, name_column="name"):
"""filters are used in SHOW queries"""
filters = ast["filter"]
if filters is None:
return None
if "Like" in filters:
left = ExpressionTreeNode(NodeType.IDENTIFIER, value="name")
left = ExpressionTreeNode(NodeType.IDENTIFIER, value=name_column)
right = ExpressionTreeNode(NodeType.LITERAL_VARCHAR, value=filters["Like"])
root = ExpressionTreeNode(
NodeType.COMPARISON_OPERATOR,
Expand Down
2 changes: 1 addition & 1 deletion opteryx/components/logical_planner/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def show_variables_query(ast, properties):
plan.add_node("show", show)
last_node = "show"

filters = custom_builders.extract_show_filter(ast["ShowVariables"])
filters = custom_builders.extract_show_filter(ast["ShowVariables"], "variable_name")
if filters:
plan.add_node(
"filter",
Expand Down
1 change: 1 addition & 0 deletions tests/sql_battery/test_shapes_and_errors_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ def test_sql_battery(statement, rows, columns, exception):
print(
f"\033[0;36m{(index + 1):04}\033[0m {printable[0:width - 1].ljust(width)}",
end="",
flush=True,
)
test_sql_battery(statement, rows, cols, err)
print(f"\033[0;32m{str(int((time.monotonic_ns() - start)/1e6)).rjust(4)}ms\033[0m ✅")
Expand Down

0 comments on commit a8be8da

Please sign in to comment.