Skip to content

Commit

Permalink
Propagate config exceptions to query
Browse files Browse the repository at this point in the history
  • Loading branch information
buremba committed Oct 12, 2024
1 parent 28627c6 commit 86cf52d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions universql/warehouse/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ def register_locations(self, tables: Locations):
def __init__(self, context: dict, query_id: str, credentials: dict, compute: dict):
super().__init__(context, query_id, credentials, compute)
duckdb_path = context.get('database_path')
self.duckdb = duckdb.connect(duckdb_path, config={
'max_memory': context.get('max_memory'),
'temp_directory': os.path.join(context.get('cache_directory'), "duckdb-staging"),
'max_temp_directory_size': context.get('max_cache_size'),
'home_directory': context.get('home_directory')
})
try:
self.duckdb = duckdb.connect(duckdb_path, config={
'max_memory': context.get('max_memory'),
'temp_directory': os.path.join(context.get('cache_directory'), "duckdb-staging"),
'max_temp_directory_size': context.get('max_cache_size'),
'home_directory': context.get('home_directory')
})
except duckdb.InvalidInputException as e:
raise QueryError(f"Unable to spin up DuckDB: {e}")
DuckDBFunctions.register(self.duckdb)
self.duckdb.install_extension("iceberg")
self.duckdb.load_extension("iceberg")
Expand Down

0 comments on commit 86cf52d

Please sign in to comment.