Firstly, this issue appears even after
TEIID-4283 fix, and is db independent.
When during materialized view's loading there is a query on the view performed, timing issues appear. In MATVIEW_AFTER_LOAD_SCRIPT there might be more commands separated by semicolon, but these commands are not performed as a single operation. In specific timing a query on such view might fail when you have a MATVIEW_AFTER_LOAD_SCRIPT like this:
user might end up querying the view right in the moment, when 'primary' materialized table (dv_matviews_mat_view) was renamed (dv_matviews_mat_view_stage) and thus there's no such table like defined in the materialized view.
Then for some queries I get:
From the logs it seems that the after load script has completed, but probably not in the source db. In logs just before the exception I see:
I attached the logs to this issue.