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: Snowflake adapter #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oliverlambson
Copy link

@oliverlambson oliverlambson commented May 2, 2024

Closes #23

Implemented a Snowflake adapter using gosnowflake.

Steps followed

  1. Add gosnowflake dependency:
    go get -u github.com/snowflakedb/gosnowflake@latest
    This changed a lot of go.mod and I have no idea if that's expected behaviour (I assumed it would only add required deps, but it seems to have bumped a bunch of versions too. I'm not a go dev, sorry)
  2. Use Redshift adapter files as base templates and modify to work with gosnowflake
  3. Update SQL queries for Driver and Helpers
  4. Test locally in nvim-dbee
    I did this by building the binary (go build) and replacing the default binary that the nvim-dbee lua config points to (in my case at /Users/oliverlambson/.local/share/nvim/dbee/bin/dbee, I'm on an M1 Mac)

Manual testing

(sorry had to redact everything because I don't have a dummy snowflake to play with)

image

@oliverlambson oliverlambson changed the title feat: Add Snowflake adapter feat: Snowflake adapter May 2, 2024
@oliverlambson oliverlambson force-pushed the feat/snowflake branch 3 times, most recently from 2f4e993 to be8c26f Compare May 2, 2024 15:43
Copy link

@AM-I-Human AM-I-Human left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I'm not a maintainer but I have some suggestion to improve it (maybe). It involves the use of SHOW instead of SELECTS to avoid waking up warehouses

Comment on lines +62 to +67
SELECT column_name, data_type
FROM information_schema.columns
WHERE
table_schema=UPPER('%s') AND
table_name=UPPER('%s')
ORDER BY ordinal_position

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use SHOW as command
to avoid warehouse costs https://docs.snowflake.com/en/sql-reference/sql/show-columns

Comment on lines +76 to +87
SELECT
table_schema AS schema_name
, table_name
, CASE
WHEN table_type = 'BASE TABLE' THEN 'TABLE'
ELSE table_type
END AS table_type
FROM
information_schema.tables
WHERE
table_schema NOT IN ('INFORMATION_SCHEMA', 'PG_CATALOG')
AND table_catalog = CURRENT_DATABASE();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Slanman3755
Copy link

Bumping this. What would it take to get this merged?

@ArthurMynl
Copy link

Re bumping it, as a data engineer I would love to be able to use snowflake inside neovim :)

@SergioQuijanoRey
Copy link

Re bumping it, as a data engineer I would love to be able to use snowflake inside neovim :)

Totally agree with this!

@phdah
Copy link
Contributor

phdah commented Feb 14, 2025

Hey @oliverlambson!

The plugin has been stale for some time, but we have actively started doing work again.
Would you mind syncing you branch, and looking over possible needed changes? Me and @MattiasMTS are pushing for a v0.2.0 release, where the focus is integration tests for the existing adapters. See discussion

Then we would be happy to review this PR.

@oliverlambson
Copy link
Author

oliverlambson commented Feb 14, 2025

@phdah i actually don't use snowflake anymore (and don't even have access to a warehouse since leaving my previous job)

perhaps @AM-I-Human, @Slanman3755, @ArthurMynl or @SergioQuijanoRey would like to pick it up?

@derekbunch
Copy link

I've actually also been working on my own fork that's rebased on top of master and trying to get show commands working (since it doesn't match the [name, data type] column order of ColumnsFromResultStream) but I'm also not a go dev so it's slow going.

I'd be willing to try and help this get across the line if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request: snowflake driver
7 participants