LCOV - code coverage report
Current view: top level - dashql-app/src/ui/vegalite - vegalite_rows.ts Coverage Total Hit
Test: DashQL 915828b Lines: 88.9 % 18 16
Test Date: 2026-11-06 19:30:32

            Line data    Source code
       1              : import type * as arrow from 'apache-arrow';
       2              : 
       3              : /// Convert an arrow row object to a vega-compatible plain object.
       4            1 : function arrowRowToObject(row: any, fields: readonly arrow.Field[]): Record<string, unknown> {
       5            1 :     const obj: Record<string, unknown> = {};
       6            1 :     for (const field of fields) {
       7            1 :         const value = row[field.name];
       8              :         // Convert BigInts to numbers for vega compatibility
       9            1 :         if (typeof value === 'bigint') {
      10            0 :             obj[field.name] = Number(value);
      11            1 :         } else if (value instanceof Date) {
      12            0 :             obj[field.name] = value.toISOString();
      13              :         } else {
      14            1 :             obj[field.name] = value;
      15              :         }
      16            1 :     }
      17            1 :     return obj;
      18            1 : }
      19              : 
      20              : /// The rows of an Arrow table as plain objects for the datasets of Vega
      21            1 : export function arrowTableToRows(table: arrow.Table): Record<string, unknown>[] {
      22            1 :     const rows: Record<string, unknown>[] = [];
      23            1 :     for (const row of table) {
      24            1 :         rows.push(arrowRowToObject(row, table.schema.fields));
      25              :     }
      26            1 :     return rows;
      27            1 : }
        

Generated by: LCOV version 2.0-1