circuithub / rel8

Hey! Hey! Can u rel8?
https://rel8.readthedocs.io
Other
154 stars 39 forks source link

Export `materialize` #260

Closed shane-circuithub closed 1 year ago

shane-circuithub commented 1 year ago

The main reason I wasn't happy with this before is that there was nothing stopping you from writing materialize query pure. This returned query would produce invalid SQL if you actually tried to use it, because it would attempt to reference a common table expression outside the scope of the WITH statement.

The "solution" here is just to throw a rebind around the result such that materialize incurs an extra Table Expr b constraint, which means that you can't return Query (Query a) because Query a can't satisfy a Table Expr constraint.