astro-sdk
astro-sdk copied to clipboard
`render` dependencies fail if SQL file name contains hyphens
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.
@ashb what are your thoughts here? Does jinja normally allow hyphens? Seems like this might be some trouble
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.
Technically this would be fixable with some hack solution of operator overloading, buuut I'm not sure we want to do that.
@ashb yes I agree i think we should just set a documentation rule taht your sql file name should be a valid identifier
Is this still relevant @tatiana ?