soumyakanti3578 commented on code in PR #4762: URL: https://github.com/apache/hive/pull/4762#discussion_r1346305581
########## ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java: ########## @@ -2161,9 +2167,14 @@ private void getMaterializationMetadata(QB qb) throws SemanticException { return; } try { - gatherCTEReferences(qb, rootClause); + Map<String, CTEClause> materializationAliasToCTEs = new HashMap<>(); + for (String key: this.aliasToCTEs.keySet()) { + CTEClause clause = this.aliasToCTEs.get(key); + materializationAliasToCTEs.put(key, new CTEClause(clause.alias, clause.cteNode, clause.withColList)); + } + gatherCTEReferences(qb, rootClause, materializationAliasToCTEs); int threshold = HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVE_CTE_MATERIALIZE_THRESHOLD); - for (CTEClause cte : Sets.newHashSet(aliasToCTEs.values())) { + for (CTEClause cte : Sets.newHashSet(materializationAliasToCTEs.values())) { Review Comment: I am adding > this.aliasToCTEs.putAll(materializationAliasToCTEs); in `getMetaData` method. Adding it in this method (`getMaterializationMetadata`) doesn't work because then this.aliasToCTEs will have all CTE clauses. This is problematic because in `getMetaData` method, we call an overloaded `getMetaData` method that tries to add the CTE clauses again into the map. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org