ShreelekhyaG commented on code in PR #4257: URL: https://github.com/apache/carbondata/pull/4257#discussion_r843998373
########## integration/spark/src/main/scala/org/apache/spark/sql/execution/command/view/CarbonCreateMVCommand.scala: ########## @@ -143,9 +143,22 @@ case class CarbonCreateMVCommand( tableIdentifier: TableIdentifier, viewManager: MVManagerInSpark, viewCatalog: MVCatalogInSpark): MVSchema = { - val logicalPlan = MVHelper.dropDummyFunction( + var logicalPlan = MVHelper.dropDummyFunction( MVQueryParser.getQueryPlan(queryString, session)) - // check if mv with same query already exists + val relatedTables = getRelatedTables(logicalPlan) + val viewRefreshMode = if (checkIsQueryNeedFullRefresh(logicalPlan) || + checkIsHasNonCarbonTable(relatedTables)) { + MVProperty.REFRESH_MODE_FULL + } else { + MVProperty.REFRESH_MODE_INCREMENTAL + } + val modifiedQueryString = MVQueryParser.checkForAvgAndModifySql(queryString) + if (viewRefreshMode.equalsIgnoreCase(MVProperty.REFRESH_MODE_INCREMENTAL)) { + // Check if average aggregate is used and derive logical plan from modified query string. + logicalPlan = MVHelper.dropDummyFunction( Review Comment: added if check to see if query contains AVG function. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@carbondata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org