Skip to content

Commit

Permalink
[fix] schema panel displays temp table (#3014)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <[email protected]>
  • Loading branch information
igorDykhta authored Mar 6, 2025
1 parent ed2b5f3 commit b4b979d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/duckdb/src/components/schema-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const SchemaPanel = ({

setColumnSchemas(result);
setTableSchema(tableSchema);
c.close();
await c.close();

// schemaUpdateTrigger indicates possible change in DuckDB
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
8 changes: 4 additions & 4 deletions src/duckdb/src/components/sql-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ export const SqlPanel: React.FC<SqlPanelProps> = ({initialSql = ''}) => {
const db = await getDuckDB();
const connection = await db.connect();

// Indicate that there may be a possible change in DuckDB.
setSchemaUpdateTrigger(Date.now());

// TODO find a cheap way to get DuckDb types with a single query to a remote resource - temp table? cte?
const tempTableName = 'temp_keplergl_table';

Expand Down Expand Up @@ -230,12 +227,15 @@ export const SqlPanel: React.FC<SqlPanelProps> = ({initialSql = ''}) => {
setError(null);
}

connection.close();
await connection.close();
} catch (e) {
setError(e as Error);
} finally {
setIsRunning(false);
}

// Indicate that there may be a possible change in DuckDB.
setSchemaUpdateTrigger(Date.now());
}, [sql]);

const onChange = useCallback(
Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/table/duckdb-table-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ Possible reasons:
}
}

c.close();
await c.close();

return error;
}
Expand All @@ -506,7 +506,7 @@ export function sanitizeDuckDBTableName(fileName: string): string {
let name = fileName.replace(/[^a-zA-Z0-9_]/g, '_');
// Ensure it doesn't start with a digit
if (/^\d/.test(name)) {
name = 't_' + name;
name = `t_${name}`;
}
return name || 'default_table';
}

0 comments on commit b4b979d

Please sign in to comment.