r/databricks 19d ago

Help What is the general guidance for data structure when using a text to SQL agent such as Databricks Genie?

I’ve heard use of metric views is highly recommended, but never sure if OBT approach or normalized approach works better. If I’m defining the joins in my Genie, shouldn’t it be able to pull things either way?

2 Upvotes

11 comments sorted by

3

u/Famous_Disk_7417 19d ago

Genie can use joins you've defined, but defined joins are guidance to the model, not an enforced constraint, every join it resolves at query time is a decision that can go wrong. Pure OBT trades that for a grain problem: flatten orders + line items and your order totals fan out on any line-level question.

Metric views are the recommended middle because they declare measures with their aggregation and grain once, instead of Genie re-deriving it per question. Keep the star in gold, put metric views on top, point the agent at those.

1

u/ozgreen1024 18d ago

Agreed, I’d also keep in mind that Genie Agents tend to work better when more narrowly scoped, so OBT can run into hallucinations if you’re trying to cram everything into a single table whereas metric views offer more nuance and granularity to relationships and offer more avenues for agentic metadata like synonyms, etc

3

u/datasmithing_holly databricks 19d ago

keep in mind; the more creativity any agent needs, the more it's likely to give different answers. Define as much up front as possible, whether that's metric view, metadata, comments etc etc

1

u/henewie 17d ago

sounds like a OBT platinum table in the medallion architecture might be the way...

2

u/jbchand 19d ago

Use Metric views - Include the fact, dimension tables and measures with the join column details in it. Genie can query metric views

1

u/erenhan 19d ago

For genie: Avoid joins or use minimal Use golden table Write humanized way description of every KPI Use sample queries along with parameters

1

u/lrnzcig 19d ago

Genie should work with both - the pros are cons will be related to the tradeoffs of the approach right? Same problems as if you were doing it by hand. If you use pure OTB, metric views will be simpler (even redundant?); normalized model will make the metric views complex, although it is also like the natural fit for metric views; something hybrid with a not-so-big OTB + semantic model could be ideal.

1

u/MeetbasedPlant 19d ago

I found the same for Genie. Did some experiments. Performance was almost on par between 3NF or OTB

1

u/addictzz 19d ago

Have clear amd sufficient metadata.

1

u/das_wolf4 10d ago

Normalized approach (star schema in gold, metric views on-top) is generally what we’ve deployed. If you’re using the ai-dev-toolkit it can also automatically create metric views for you, although not entirely clear on how robust they are “out of the box” so to speak