Compound keys on Genie

JYvesLimantour
New Contributor III

Is it just me or Genie´s generated SQL code failes to use composite keys -of the underlying related tables- as its default behavoir, regardless of the model having relationships declared explicitly.

Sometimes I have fixed this scenario by using an instruction -plain text-, sometimes by forcing the sql as an instruction but every time I have a new set of tables related by means of a composite key, Genie just won't use them as its default behavior. Then I have to juggle.

¿Are you experiencing this same behavior?

¿How are you tackling it?

SP_6721
Honored Contributor II

Hi @JYvesLimantour 

Genie struggles with composite keys by design. A few things that might help:

  • Clearly define your primary and foreign key relationships in Unity Catalog.
  • Add example SQL queries that include composite joins to give Genie better context.
  • Include explicit join instructions in your Genie space when needed.
  • For more complex joins, you could try using materialized views, predefined joins, or even things like surrogate keys or hashed keys
  • For complex joins, you could try using materialized views or predefined joins.

View solution in original post

What has been useful the most is adding sql instructions using composite keys.