web / lib/jobs/handlers/schema-detection-job
lib/jobs/handlers/schema-detection-job
Defines the job handler for detecting the schema from a batch of imported data.
This job processes a batch of rows from the import file to progressively build a schema. It skips rows that were identified as duplicates to ensure the schema is based on unique data.
Key responsibilities include:
- Using a
ProgressiveSchemaBuilderto infer data types and properties for each column. - Detecting fields that could be used for geocoding (e.g., address, latitude, longitude).
- Storing the evolving schema and the builder’s state in the
import-jobsdocument.
After processing all batches, the import job transitions to the SCHEMA_VALIDATION stage.
Variables
schemaDetectionJob
constschemaDetectionJob:object
Type declaration
slug
slug:
"detect-schema"=JOB_TYPES.DETECT_SCHEMA
handler()
handler: (
context) =>Promise<{output: {completed:true;batchNumber:number;rowsProcessed:number;hasMore:false; }; } | {output: {batchNumber:number;rowsProcessed:number;hasMore:boolean; }; }>
Parameters
context
Returns
Promise<{ output: { completed: true; batchNumber: number; rowsProcessed: number; hasMore: false; }; } | { output: { batchNumber: number; rowsProcessed: number; hasMore: boolean; }; }>