Snowflake-Labs / django-snowflake

MIT License
59 stars 15 forks source link

Add support for INTERVAL math where the interval is a column #27

Open timgraham opened 2 years ago

timgraham commented 2 years ago

A queryset like:

Experiment.objects.filter(start=F('start') + F('estimated_time')

where estimated_time is a DurationField, generates SQL:

WHERE "experiment"."start" = ("experiment"."start" + INTERVAL '"expressions_ExPeRiMeNt"."estimated_time" MICROSECONDS')

but INTERVAL doesn't support column names. (SQL compilation error: syntax error line 1 at position 0 unexpected '"experiment"'.)

Perhaps Snowflake could add support for this. For example, MySQL allows:

INTERVAL `experiment`.`estimated_time` MICROSECOND