CREATE MATERIALIZED VIEW <viewname>
TO <targettablename_version>
AS SELECT ... FROM <sourcetablename_version> ...
Their aggregation file only contains the SELECT clause though. We take that string and append it to the create query. That means they can't specify the TO . Currently, it's slightly magical because we assume the target table is the same name as the aggregation file, and we always assume the latest version (whatever version is in package.json). But what if the target table is not on the latest version?
E.g. they have Source & Target data models. They both start out at 0.0. They make a change to Source model, bump version. So now Source is at 0.1, but Target is still at 0.0.
A materialized view query is like this:
Their aggregation file only contains the SELECT clause though. We take that string and append it to the create query. That means they can't specify the TO. Currently, it's slightly magical because we assume the target table is the same name as the aggregation file, and we always assume the latest version (whatever version is in package.json). But what if the target table is not on the latest version?
E.g. they have Source & Target data models. They both start out at 0.0. They make a change to Source model, bump version. So now Source is at 0.1, but Target is still at 0.0.