Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SQLRooms Issue: DATE and DECIMAL types display incorrectly in QueryResultPanel #286

@mgozdev

Description

@mgozdev

Summary

When using SQLRooms with DuckDB-WASM to display query results from Parquet files, DATE and DECIMAL columns are not rendered correctly:

  • DATE columns display as Date32<DAY> instead of a formatted date string
  • DECIMAL columns display as raw scaled integers (e.g., 15130000000 instead of 1.513) unless castDecimalToDouble is enabled, which then causes floating-point precision issues (e.g., 1.6700000000000002 instead of 1.67)

Environment

  • @sqlrooms/sql-editor: 0.26.0
  • @sqlrooms/data-table: 0.26.0
  • @sqlrooms/duckdb: 0.26.0
  • @duckdb/duckdb-wasm: 1.30.0
  • Browser: Chrome

Steps to Reproduce

  1. Create a DuckDB connector with type casting options:
const duckDbConnector = createWasmDuckDbConnector({
  query: {
    castDecimalToDouble: true,
    castTimestampToDate: true,
    castBigIntToDouble: true,
  },
});
  1. Load a Parquet file with DATE and DECIMAL columns
  2. Query the table and view results in QueryResultPanel

Expected vs Actual Behavior

Column Type | Expected | Actual -- | -- | -- DATE | 2025-12-12 | Date32 DECIMAL(20,10) without config | 1.67 | 16700000000 (raw scaled integer) DECIMAL(20,10) with castDecimalToDouble | 1.67 | 1.6700000000000002 (float precision error)

Root Cause

DATE Issue: In useArrowDataTable.js, the DATE handling assumes the value is already a JavaScript Date instance:

if (arrow.DataType.isDate(type)) {
    if (value instanceof Date) {  // <-- This check fails for Arrow Date32
        return value.toISOString();
    }
}
return String(value);  // Falls through, showing "Date32<DAY>"

DuckDB-WASM's castTimestampToDate only affects TIMESTAMP, not DATE. The Arrow Date32 value is an integer (days since epoch), not a Date instance.

Related Issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions