-
Notifications
You must be signed in to change notification settings - Fork 16
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
Snowflake - Connection Cell and SQL Cell #61
Merged
cristineguadelupe
merged 9 commits into
livebook-dev:main
from
cristineguadelupe:cg-snowflake
Aug 30, 2023
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2ea7a93
Snowflake - initial support
cristineguadelupe 9752e00
Snowflake - initial support for query
cristineguadelupe 63539bf
Improvements
cristineguadelupe b344eac
Build uri
cristineguadelupe 2937256
:required for BaseSecret
cristineguadelupe 82bf4b1
Tests for code generation
cristineguadelupe 41ec919
Tests for sql generation
cristineguadelupe c13b736
Applying suggestions
cristineguadelupe dce2642
Bump elixir version for CI
cristineguadelupe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -122,7 +122,7 @@ defmodule KinoDB.SQLCell do | |||||||||||||||||
_ -> nil | ||||||||||||||||||
end | ||||||||||||||||||
else | ||||||||||||||||||
_ -> nil | ||||||||||||||||||
_ -> connection_from_adbc(connection) | ||||||||||||||||||
end | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -136,6 +136,15 @@ defmodule KinoDB.SQLCell do | |||||||||||||||||
|
||||||||||||||||||
defp connection_type(_connection), do: nil | ||||||||||||||||||
|
||||||||||||||||||
defp connection_from_adbc(connection) when is_pid(connection) do | ||||||||||||||||||
with true <- Code.ensure_loaded?(Adbc), | ||||||||||||||||||
true <- is_snowflake_conn?(connection) do | ||||||||||||||||||
"snowflake" | ||||||||||||||||||
else | ||||||||||||||||||
_ -> nil | ||||||||||||||||||
end | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
@impl true | ||||||||||||||||||
def to_attrs(ctx) do | ||||||||||||||||||
%{ | ||||||||||||||||||
|
@@ -166,6 +175,10 @@ defmodule KinoDB.SQLCell do | |||||||||||||||||
to_quoted(attrs, quote(do: Exqlite), fn n -> "?#{n}" end) | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
defp to_quoted(%{"connection" => %{"type" => "snowflake"}} = attrs) do | ||||||||||||||||||
to_quoted(attrs, quote(do: Adbc.Connection), fn n -> "?#{n}" end) | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
defp to_quoted(%{"connection" => %{"type" => "bigquery"}} = attrs) do | ||||||||||||||||||
to_req_quoted(attrs, fn _n -> "?" end, :bigquery) | ||||||||||||||||||
end | ||||||||||||||||||
|
@@ -271,4 +284,9 @@ defmodule KinoDB.SQLCell do | |||||||||||||||||
defp parameterize(<<char::utf8, rest::binary>>, raw, params, n, next) do | ||||||||||||||||||
parameterize(rest, <<raw::binary, char::utf8>>, params, n, next) | ||||||||||||||||||
end | ||||||||||||||||||
|
||||||||||||||||||
defp is_snowflake_conn?(conn) when conn == self(), do: false | ||||||||||||||||||
defp is_snowflake_conn?(conn) when is_pid(conn), do: is_snowflake_conn?(:sys.get_state(conn)) | ||||||||||||||||||
defp is_snowflake_conn?(%{queue: _, lock: _, conn: conn}) when is_reference(conn), do: true | ||||||||||||||||||
defp is_snowflake_conn?(_), do: false | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adbc.Connection.get_driver |
||||||||||||||||||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.