ParsedSelectStmt rewriteAsMV ( Table view ) { m_groupByColumns . clear ( ) ; m_distinctGroupByColumns = null ; m_groupByExpressions . clear ( ) ; m_distinctProjectSchema = null ; m_distinct = m_hasAggregateExpression = m_hasComplexGroupby = m_hasComplexAgg = false ; // Resets paramsBy* filters, assuming that it's equivalent to "SELECT * from MV". // In future, this needs update to accommodate for revised filters (e.g. removes // one or more filters). setParamsByIndex ( new TreeMap <> ( ) ) ; m_paramsById . clear ( ) ; m_paramValues = null ; // m_sql does not need updating m_tableList . clear ( ) ; m_tableList . add ( view ) ; // reset m_tableAliasMap that keeps tracks of sub-queries m_tableAliasMap . clear ( ) ; m_tableAliasListAsJoinOrder . clear ( ) ; m_tableAliasListAsJoinOrder . add ( view . getTypeName ( ) ) ; m_joinTree = new TableLeafNode ( 0 , null , null , generateStmtTableScan ( view ) ) ; prepareMVBasedQueryFix ( ) ; // update MaterializedViewFixInfo when partition key comes from multiple tables. return this ; }
Updates miscellaneous fields as part of rewriting as materialized view .