Skip to content

Commit

Permalink
snowflake support
Browse files Browse the repository at this point in the history
  • Loading branch information
greenmtnboy committed Jun 19, 2024
1 parent 318c049 commit bd7236d
Show file tree
Hide file tree
Showing 7 changed files with 458 additions and 432 deletions.
19 changes: 19 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
DataType,
)
from preql import Environment, Executor, Dialects
from preql.core.enums import Modifier
from preql.parser import parse_text
from starlette.background import BackgroundTask
from trilogy_public_models import models as public_models
Expand Down Expand Up @@ -284,6 +285,22 @@ def create_connection(connection: ConnectionInSchema):
executor = Executor(
dialect=connection.dialect, engine=engine, environment=environment
)
elif connection.dialect == Dialects.SNOWFLAKE:
if not connection.extra or not all([x in connection.extra for x in ["username", "password", "account"]]):
raise HTTPException(
status_code=400,
detail="Snowflake requires a username, password, and account to be set",
)
assert connection.extra
username = connection.extra["username"]
password = connection.extra["password"]
account = connection.extra["account"]
engine = create_engine(
f"snowflake://{username}:{password}@{account}",
)
executor = Executor(
dialect=connection.dialect, engine=engine, environment=environment
)
elif connection.dialect == Dialects.DUCK_DB:
executor = Executor(
dialect=connection.dialect,
Expand Down Expand Up @@ -440,6 +457,8 @@ def run_query(query: QueryInSchema):
),
)
for col in statement.output_columns
if col not in statement.hidden_columns

]
elif isinstance(statement, (ProcessedShowStatement)):
select: ProcessedQuery | ProcessedQueryPersist = statement.output_values[0] # type: ignore # noqa: E501
Expand Down
Binary file modified backend/requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has a
npm run dev

## WSL

export DISPLAY=$(hostname).local:0
start xlaunch or equivalent
Loading

0 comments on commit bd7236d

Please sign in to comment.