astro-sdk icon indicating copy to clipboard operation
astro-sdk copied to clipboard

`render` dependencies fail if SQL file name contains hyphens

Open kentdanas opened this issue 3 years ago • 4 comments
trafficstars

Description When using render, if a SQL file has a hyphen - in the name, any downstream dependencies that reference it will fail.

For example, a task with

SELECT *
FROM {{combine-homes}}
WHERE ROOMS > 0
AND ROOMS < 50

that references combine-homes.sql fails with jinja2.exceptions.UndefinedError: 'combine' is undefined. If the hyphens are replaced with underscores (combine_homes.sql), it works with no issues.

Desired Behavior Either hyphens should be allowed in SQL file names, or if this is not feasible, we should be explicit in our docs that they are not allowed and underscores should be used instead.

kentdanas avatar Feb 25 '22 17:02 kentdanas

@ashb what are your thoughts here? Does jinja normally allow hyphens? Seems like this might be some trouble

dimberman avatar Mar 01 '22 03:03 dimberman

No, jinja cant allow hyphens.

That is combine - homes -- i.e. a subtract operator. Variables have to follow python identifier rules.

This is un-fixable with jinja.

ashb avatar Mar 02 '22 14:03 ashb

Technically this would be fixable with some hack solution of operator overloading, buuut I'm not sure we want to do that.

ashb avatar Mar 02 '22 14:03 ashb

@ashb yes I agree i think we should just set a documentation rule taht your sql file name should be a valid identifier

dimberman avatar Mar 05 '22 01:03 dimberman

Is this still relevant @tatiana ?

sunank200 avatar Jan 19 '23 09:01 sunank200