From d3fd09815c5500e9598403609be3cf73cf528997 Mon Sep 17 00:00:00 2001 From: nicolst <35232838+nicolst@users.noreply.github.com> Date: Wed, 15 Jul 2026 11:19:04 +0200 Subject: [PATCH] fix: parquedit data_path and home_directory Use /tmp as home_directory so duckdb can write Set data path to /tmp/{team} for writing, then manually override afterward --- labradoor/internal/parquedit/handler.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/labradoor/internal/parquedit/handler.go b/labradoor/internal/parquedit/handler.go index e31cf9a..7d1d9eb 100644 --- a/labradoor/internal/parquedit/handler.go +++ b/labradoor/internal/parquedit/handler.go @@ -112,23 +112,33 @@ func (c *Client) EnableForTeam(w http.ResponseWriter, req *http.Request) { //#nosec G701 -- We have sanitized the inputs, and query placeholders don't seem to work. if _, err := duckdb.ExecContext(req.Context(), fmt.Sprintf(` + SET home_directory='/tmp'; INSTALL ducklake; LOAD ducklake; INSTALL postgres; LOAD postgres; ATTACH 'ducklake:postgres:%s' AS %[2]s (DATA_PATH '/tmp/%[2]s', METADATA_SCHEMA %[2]s, DATA_INLINING_ROW_LIMIT 300, - AUTOMATIC_MIGRATION TRUE); - `, c.databaseUrl, schema)); err != nil { + AUTOMATIC_MIGRATION TRUE, + OVERRIDE_DATA_PATH TRUE); + `, c.databaseUrl, schema, team)); err != nil { _ = httplog.SetError(req.Context(), err) w.WriteHeader(http.StatusInternalServerError) return } log.Info("initialized ducklake schema") + log.Info("overriding ducklake data_path") + result, err := c.db.Exec(req.Context(), "UPDATE "+schema+".ducklake_metadata SET value = 'gs://ssb-"+team+"-data-produkt-prod/.parquedit_data/' WHERE key = 'data_path'") + if err != nil { + _ = httplog.SetError(req.Context(), err) + w.WriteHeader(http.StatusInternalServerError) + return + } + log.Info("overrode ducklake data_path", "result", result) log.Info("grant on schema", "user", saMember) - result, err := c.db.Exec(req.Context(), "GRANT CREATE, USAGE ON SCHEMA "+schema+" TO \""+saMember+"\"") + result, err = c.db.Exec(req.Context(), "GRANT CREATE, USAGE ON SCHEMA "+schema+" TO \""+saMember+"\"") if err != nil { _ = httplog.SetError(req.Context(), err) w.WriteHeader(http.StatusInternalServerError)