Skip to content

Commit

Permalink
add snowflake command
Browse files Browse the repository at this point in the history
  • Loading branch information
buremba committed Aug 3, 2024
1 parent d47d8d9 commit 2c7d4c5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions universql/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

import click
import pkg_resources
import psutil
import requests
import uvicorn
Expand All @@ -22,7 +23,14 @@
"max_cache_size": sizeof_fmt(psutil.disk_usage("./").free * 0.8)
}

@click.command("snowflake", epilog='Check out our docs at https://github.com/buremba/universql for more details')

@click.group()
@click.version_option(version=pkg_resources.get_distribution('universql').version)
def cli():
pass


@cli.command(epilog='Check out our docs at https://github.com/buremba/universql for more details')
@click.option('--account',
help='The account to use. Supports both Snowflake and Polaris (ex: rt21601.europe-west2.gcp)',
prompt='Account ID')
Expand All @@ -48,7 +56,7 @@
type=str)
@click.option('--max-cache-size', type=str, default=DEFAULTS["max_cache_size"],
help='DuckDB max_temp_directory_size and total total (default: 80% of total memory)')
def cli(host, port, ssl_keyfile, ssl_certfile, account, catalog, compute, **kwargs):
def snowflake(host, port, ssl_keyfile, ssl_certfile, account, catalog, compute, **kwargs):
context__params = click.get_current_context().params
params = {k: v for k, v in context__params.items() if
v is not None and k not in ["host", "port"]}
Expand All @@ -66,7 +74,7 @@ def cli(host, port, ssl_keyfile, ssl_certfile, account, catalog, compute, **kwar

adjective = "apparently" if auto_catalog_mode else ""
logger.info(f"UniverSQL is starting reverse proxy for {account}.snowflakecomputing.com, "
f"it's {adjective} a {context__params['catalog']} server. Happy compute!")
f"it's {adjective} a {context__params['catalog']} server. Happy compute!")

if compute == Compute.AUTO.value:
logger.info("The queries run on DuckDB and fallback to Snowflake if they fail.")
Expand Down Expand Up @@ -121,4 +129,4 @@ def filter(self, record: logging.LogRecord) -> bool:
uvicorn_logger.addFilter(EndpointFilter(path="/session/v1/login-request"))

if __name__ == '__main__':
cli()
cli(prog_name="universql")

0 comments on commit 2c7d4c5

Please sign in to comment.