SemiLayerDocs

Shaping your data

The column names and shapes in your source rarely match the column names and shapes your app wants in the index. SemiLayer's mapping layer closes the gap in your config — no ETL job, no view, no extra moving part.

Every FieldConfig on a lens has five mapping knobs:

fields: {
  displayName: {
    type:     'text',
    from:     ['first_name', 'last_name'],   // ← source columns (rename or merge)
    merge:    'concat',                       // ← how to combine multiple
    separator: ' ',                           // ← required for concat
    transform: { type: 'trim' },              // ← transforms applied after resolution
    nullAs:    'Anonymous',                   // ← replace null
  },
}

Three patterns you'll hit first

Rename a column.

product_name: { type: 'text', from: 'name_en' }   // source column 'name_en' becomes 'product_name'

Round a price to two decimals.

priceUsd: { type: 'number', from: 'price_cents', transform: { type: 'round', decimals: 2 } }

Compose a full name from two columns.

fullName: {
  type: 'text',
  from: ['first_name', 'last_name'],
  merge: 'concat',
  separator: ' ',
}

That's 80% of the mapping you'll ever write.

The full story lives in Data Mapping

  • Overview — all five knobs, how they fit together
  • Source resolutionfrom, merge, separator, the two merge strategies
  • Transforms — every built-in transform + chaining + custom JS
  • Recipes — common patterns (derived fields, null defaults, cents→dollars, JSON unpacking)

Head there when you start writing more than trivial renames.