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

display improvements to %sqlcmd snippets #648

Closed
edublancas opened this issue Jun 22, 2023 · 6 comments · Fixed by #716
Closed

display improvements to %sqlcmd snippets #648

edublancas opened this issue Jun 22, 2023 · 6 comments · Fixed by #716
Assignees
Labels
stash Label used to categorize issues that will be worked on next

Comments

@edublancas
Copy link

we need to do some improvements when showing feedback to the user

for context: snippets.ipynb.zip

@edublancas edublancas added the stash Label used to categorize issues that will be worked on next label Jun 22, 2023
@bbeat2782
Copy link

If you have nothing in mind what I should work on next, I can start working on this.

Acceptance Criteria

  1. Calling %sqlcmd snippets when there is a no snippet prints out No snippets stored message using the display module.
  2. Calling %sqlcmd snippets when there are stored snippets displays table and snippet for all stored snippets.
  3. Modify %sqlcmd snippets documentation to reflect this change
  4. Modify test functions

@edublancas
Copy link
Author

sure, please work on this

@bbeat2782
Copy link

@edublancas
I have one question about the implementation of this issue.

Let's say a user connects to connection A, creates a snippet under connection A, and then connects to another connection B. In this case, is the expected behavior of calling %sqlcmd snippets when in connection B printing out No snippets stored since no snippets were created under connection B?

@edublancas
Copy link
Author

interesting point. right now, snippets are connection-independent so switching connections won't have any effect. they'll still show the same ones. But I like this Idea, we can work on it later.

@bbeat2782
Copy link

bbeat2782 commented Jun 30, 2023

Sorry for not providing a clear explanation in my first question. @edublancas

You are right about snippets being connection-independent. So there is no problem with getting a stored snippet from different connections. The problem occurs when I try to display a result of a snippet when the snippet uses a table that is not present in the current connection.

The following code is a short demonstration. The full notebook is here
(connection_change_demonstration.ipynb.zip).

After
%sql duckdb://
%%sql --save gentoo SELECT * FROM penguins.csv where species == 'Gentoo'

%sqlcmd snippets gentoo returns the stored snippet and %sql SELECT * FROM penguins.csv where species == 'Gentoo' returns a result of the snippet.

After changing the connection with
%sql sqlite://

%sqlcmd snippets gentoo still returns the stored snippet but %sql SELECT * FROM penguins.csv where species == 'Gentoo' does not return the same result because of (sqlite3.OperationalError) no such table: penguins.csv error.

Since the objective is to show a table and snippet when %sqlcmd snippets is called but some snippets are not runnable under some connections, should I only include snippets for snippets that are using tables not present in the current connection or should I try different connections to display tables for all snippets?

@edublancas
Copy link
Author

thanks for providing more feedback. I think let's keep it simple and allow users to run any snippets on any connection, it's on their side to ensure that whatever snippet they want to run is valid in the current connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stash Label used to categorize issues that will be worked on next
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants