Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions server/querylog.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func NewQueryLogger(cfg Config) (*QueryLogger, error) {
if err != nil {
return nil, fmt.Errorf("querylog: open duckdb: %w", err)
}
// Pin to a single connection so ATTACH/CREATE TABLE state is shared with INSERT calls.
db.SetMaxOpenConns(1)

// Set extension directory under DataDir so DuckDB doesn't rely on $HOME/.duckdb
extDir := filepath.Join(cfg.DataDir, "extensions")
Expand Down Expand Up @@ -123,9 +125,9 @@ func NewQueryLogger(cfg Config) (*QueryLogger, error) {
query VARCHAR NOT NULL,
transpiled_query VARCHAR,
query_kind VARCHAR,
normalized_query_hash UBIGINT,
result_rows BIGINT DEFAULT 0,
written_rows BIGINT DEFAULT 0,
normalized_query_hash BIGINT,
result_rows BIGINT,
written_rows BIGINT,
exception_code VARCHAR,
exception VARCHAR,
user_name VARCHAR NOT NULL,
Expand All @@ -134,9 +136,9 @@ func NewQueryLogger(cfg Config) (*QueryLogger, error) {
client_port INTEGER,
application_name VARCHAR,
pid INTEGER,
worker_id INTEGER DEFAULT -1,
is_transpiled BOOLEAN DEFAULT FALSE,
protocol VARCHAR DEFAULT 'simple'
worker_id INTEGER,
is_transpiled BOOLEAN,
protocol VARCHAR
)`
if _, err := db.Exec(createTable); err != nil {
_ = db.Close()
Expand All @@ -145,7 +147,7 @@ func NewQueryLogger(cfg Config) (*QueryLogger, error) {

// Configure data inlining
inlineStmt := fmt.Sprintf(
"CALL ducklake.set_option('data_inlining_row_limit', %d, schema_name => 'system', table_name => 'query_log')",
"CALL ducklake.set_option('data_inlining_row_limit', %d, schema => 'system', table_name => 'query_log')",
cfg.QueryLog.DataInliningRowLimit)
if _, err := db.Exec(inlineStmt); err != nil {
slog.Warn("querylog: failed to set data_inlining_row_limit, continuing without it.", "error", err)
Expand Down Expand Up @@ -257,7 +259,7 @@ func (ql *QueryLogger) flushBatch(batch []QueryLogEntry) {
truncateQuery(e.Query),
truncateNullableQuery(e.TranspiledQuery),
e.QueryKind,
e.NormalizedHash,
int64(e.NormalizedHash),
e.ResultRows,
e.WrittenRows,
e.ExceptionCode,
Expand Down
Loading