sripathikrishnan / jinjasql

Template Language for SQL with Automatic Bind Parameter Extraction
MIT License
820 stars 90 forks source link

Use field value as function parameter #36

Open aguspina opened 3 years ago

aguspina commented 3 years ago

I'm trying to exec this query in Superset-SQLab

SELECT {{gender_enum(users.gender)}} as gender
from users;

The gender_enum is defined like this

lambda x: ['Femenino', 'Masculino', 'Otro', 'Prefiere no decir'][x]

The gender field could be 0, 1, 2 or 3. It's an enum.

Of course, in jinja context, users.gender does not exist. I'm not finding a way to solve this, can you help me please?

Thanks!!