anfra docsAlpha
Semantic layerExisting semantic layers

Looker (LookML)

Convert Looker views and explores into anfra AML models and datasets with a coding agent.

If your semantic layer lives in LookML, you don't need to rewrite it by hand. A coding agent with the anfra-convert-looker skill converts your Looker views and explores into anfra data models and datasets. Dashboards are not converted.

Looker concepts in anfra

A Looker view maps to an anfra model, and a Looker explore maps to an anfra dataset. The two aren't exactly the same:

LookeranfraDifference
View (.view.lkml)Model (.model.aml)Same purpose, different syntax. Both represent a table or a SQL query and hold its dimensions and measures.
Derived tableQuery model (type: 'query')A model built from a SQL query instead of a table.
ExploreDataset (.dataset.aml)In Looker, users query from an explore's base view. In anfra, they query any model in the dataset.
join in an exploreRelationshipYou declare how models relate once, and anfra writes the joins from the fields a query uses.
DimensionDimensionSame.
Measuremeasure on the model, or a metric on the datasetA metric can combine fields from several models.
Model (.model.lkml)No single objectIts explores become datasets, and its connection becomes data_source_name on each model and dataset.

For example, the join in this explore:

ecommerce.model.lkml
explore: orders {
  join: users {
    sql_on: ${orders.user_id} = ${users.id} ;;
    relationship: many_to_one
  }
}

becomes a relationship in the dataset, where > means many-to-one:

orders_dataset.dataset.aml
Dataset orders_dataset {
  models: [orders, users]
  relationships: [
    relationship(orders.user_id > users.id, true)
  ]
}

Convert a project

Converting LookML to AML
  • Looker
  • LookML project — Your local folder of .view.lkml and .model.lkml files
  • anfra
  • Sketch AML — A first draft of each model and dataset, with TODO and REVIEW comments where the script needs help
  • Models & datasets — Valid AML that you review and commit
  • lookml → sketch (Skill: conversion script)
  • sketch → aml (Skill: AI agent)

Set up your coding agent with the anfra plugin, put your Looker project next to your anfra project, and ask your agent. In Claude Code:

/anfra:anfra-convert-looker convert ../looker-project into this anfra project

The skill works in two passes:

  1. Script: converts the structure and every parameter with a fixed mapping, and writes a model per view and a dataset per explore. Where it can't convert something, it leaves a TODO comment that quotes the original LookML. Where the result may behave differently, it leaves a REVIEW comment.
  2. Agent: resolves each TODO and REVIEW comment, on a large project, it splits the work across subagents.

Lineage

Each generated AML file starts with // looker-source: comment lines that name the Looker files it came from. Keep them when you edit the file.

To trace models back to Looker, add your Looker project as a context source and run anfra ingest:

.anfra/context_sources.yml
sources:
  - name: looker
    type: lookml
    local: { path: ../looker-project }

anfra then records each Looker file as the upstream of the AML files converted from it. Trace a model with anfra lineage, or show it in a data app with Anfra.lineage():

anfra lineage --targets '[{"parent":"listings"}]'

On this page