Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
neelasha23 committed May 29, 2023
1 parent 538a9da commit 640356b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
26 changes: 12 additions & 14 deletions src/sql/magic_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,8 @@ def execute(self, line="", cell="", local_ns=None):
if cmd.args.with_:
util.show_deprecation_warning()
if cmd.args.line[0] in {"box", "boxplot"}:
with_ = None
if util.is_saved_snippet(table):
with_ = [table]
else:
util.is_table_exists(table)
if with_:
print(f"Plotting using saved snippet : {with_}")
with_ = self._check_table_exists(table)

return plot.boxplot(
table=table,
column=column,
Expand All @@ -91,13 +86,7 @@ def execute(self, line="", cell="", local_ns=None):
conn=None,
)
elif cmd.args.line[0] in {"hist", "histogram"}:
with_ = None
if util.is_saved_snippet(table):
with_ = [table]
else:
util.is_table_exists(table)
if with_:
print(f"Plotting using saved snippet : {with_}")
with_ = self._check_table_exists(table)
return plot.histogram(
table=table,
column=column,
Expand All @@ -109,3 +98,12 @@ def execute(self, line="", cell="", local_ns=None):
raise exceptions.UsageError(
f"Unknown plot {cmd.args.line[0]!r}. Must be: 'histogram' or 'boxplot'"
)

@staticmethod
def _check_table_exists(table):
with_ = None
if util.is_saved_snippet(table):
with_ = [table]
else:
util.is_table_exists(table)
return with_
4 changes: 1 addition & 3 deletions src/tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ def test_parsed_sql_when_using_with(ip, sql_magic):
""",
)

cmd = SQLCommand(
sql_magic, ip.user_ns, line="", cell="SELECT * FROM author_one"
)
cmd = SQLCommand(sql_magic, ip.user_ns, line="", cell="SELECT * FROM author_one")

sql = "WITH `author_one` AS (\n\n SELECT * FROM author LIMIT 1\n )\n\
SELECT * FROM author_one"
Expand Down

0 comments on commit 640356b

Please sign in to comment.