@@ -199,22 +199,38 @@ export const computeSamplingRate = async(req_id:number): Promise<number> => {
199199 return sample_fraction ;
200200}
201201
202+ function isScalarNumericDuckType ( type : string ) : boolean {
203+ const T = type . toUpperCase ( ) ;
204+ // reject containers
205+ if ( T . includes ( 'LIST' ) || T . includes ( '[]' ) || T . startsWith ( 'STRUCT' ) || T . startsWith ( 'MAP' ) || T . startsWith ( 'UNION' ) ) {
206+ return false ;
207+ }
208+ // allow numeric scalars
209+ return / ^ ( T I N Y I N T | S M A L L I N T | I N T E G E R | B I G I N T | H U G E I N T | U T I N Y I N T | U S M A L L I N T | U I N T E G E R | U B I G I N T | R E A L | F L O A T | D O U B L E | D E C I M A L ) / . test ( T ) ;
210+ }
211+
202212export async function prepareDbForReqId ( reqId : number ) : Promise < void > {
203- const startTime = performance . now ( ) ; // Start time
204- try {
213+ const startTime = performance . now ( ) ;
214+ try {
205215 const fileName = await indexedDb . getFilename ( reqId ) ;
206- //console.log(`prepareDbForReqId for ${reqId} fileName:${fileName}`);
207216 const duckDbClient = await createDuckDbClient ( ) ;
208217 await duckDbClient . insertOpfsParquet ( fileName ) ;
209- const colNames = await duckDbClient . queryForColNames ( fileName ) ;
218+
219+ // Get typed columns and keep only scalar numerics (no arrays/lists)
220+ const colTypes = await duckDbClient . queryColumnTypes ( fileName ) ;
221+ const scalarNumericCols = colTypes
222+ . filter ( c => isScalarNumericDuckType ( c . type ) )
223+ . map ( c => c . name ) ;
224+
210225 await updateAllFilterOptions ( reqId ) ;
211- //console.trace(`prepareDbForReqId reqId:${reqId} colNames:`, colNames);
212- setElevationDataOptionsFromFieldNames ( reqId . toString ( ) , colNames ) ;
226+ //console.trace(`prepareDbForReqId reqId:${reqId} colNames:`, scalarNumericCols);
227+ // Use filtered names so arrays never reach the chart store
228+ setElevationDataOptionsFromFieldNames ( reqId . toString ( ) , scalarNumericCols ) ;
213229 } catch ( error ) {
214230 console . error ( 'prepareDbForReqId error:' , error ) ;
215231 throw error ;
216- } finally {
217- const endTime = performance . now ( ) ; // End time
232+ } finally {
233+ const endTime = performance . now ( ) ;
218234 console . log ( `prepareDbForReqId for ${ reqId } took ${ endTime - startTime } milliseconds.` ) ;
219235 }
220236}
0 commit comments