Skip to content

server: keep temp tables out of the dataset metadata sync - #522

Open
ymatrix1 wants to merge 1 commit into
goccy:mainfrom
ymatrix1:fix/temp-tables-not-dataset-metadata
Open

ymatrix1 wants to merge 1 commit into
goccy:mainfrom
ymatrix1:fix/temp-tables-not-dataset-metadata

Conversation

@ymatrix1

@ymatrix1 ymatrix1 commented Sep 23, 2026 •

Copy link
Copy Markdown

Depends on goccy/googlesqlite#92: with googlesqlite v0.3.1 the engine's own cleanup error comes first.

Problem

A script that creates a temp table and drops it fails, after every statement has run:

CREATE TEMP TABLE a AS SELECT 1 AS x;
DROP TABLE a;
-- unexpected table name path: [<project> a]

It is reported as jobInternalError, so clients retry it and it surfaces only after their retry deadline.

Cause

syncCatalog passes every table in ChangedCatalog.Table.Added and Deleted to addTableMetadata / deleteTableMetadata, temp tables included. A temp table's name path is [project, table], with no dataset, so both reject it.

Fix

syncCatalog skips temp tables in both directions. They are scoped to the script that created them and belong to no dataset, so there is no dataset metadata to add or remove.

Tests

server/temp_table_script_test.go: three scripts (CTAS then DROP, a temp table left for the cleanup, CREATE and DROP inside BEGIN ... END). Each must succeed, and afterwards no temp table may be listed as dataset metadata.

Before (with googlesqlite#92 applied, so this layer's error is the one that shows):

temp_table_script_test.go:55: CREATE TEMP TABLE a AS SELECT 1 AS x; DROP TABLE a; SELECT 1 AS done: run: googleapi: Error 400: failed to add query result to dynamic destination table: dataset ...: dataset is already created, jobInternalError
--- FAIL: TestScriptDropsItsTempTable

That message is the Go client retrying the insert after the first attempt failed with unexpected table name path.

After: passes. go test ./... has no new failures against main.

A script that creates a temp table and drops it itself failed after every
statement had run: syncCatalog handed the dropped temp table to
deleteTableMetadata, which rejects its two-part name path with
"unexpected table name path: [<project> <table>]". The job then failed
with jobInternalError, which clients retry, so the error surfaced only
after the client's retry deadline.

Temp tables are scoped to the script that created them and belong to no
dataset, so skip them in both directions of the sync.

The regression test also needs googlesqlite to stop failing the
end-of-script cleanup of a temp table the script already dropped
(Flip-to/googlesqlite fix/temp-table-cleanup-after-drop); with stock
googlesqlite v0.3.1 that error comes first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant