Yash-cor commented on code in PR #34163:
URL: https://github.com/apache/shardingsphere/pull/34163#discussion_r1899945987


##########
infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/expression/type/SubquerySegmentBinder.java:
##########
@@ -46,7 +48,13 @@ public static SubquerySegment bind(final SubquerySegment 
segment, final SQLState
         SQLStatementBinderContext selectBinderContext =
                 new SQLStatementBinderContext(binderContext.getMetaData(), 
binderContext.getCurrentDatabaseName(), binderContext.getHintValueContext(), 
segment.getSelect());
         
selectBinderContext.getExternalTableBinderContexts().putAll(binderContext.getExternalTableBinderContexts());
+        
selectBinderContext.getCommonTableExpressionsSegmentsUniqueAliases().addAll(binderContext.getCommonTableExpressionsSegmentsUniqueAliases());
         SelectStatement boundSelectStatement = new 
SelectStatementBinder(outerTableBinderContexts).bind(segment.getSelect(), 
selectBinderContext);
-        return new SubquerySegment(segment.getStartIndex(), 
segment.getStopIndex(), boundSelectStatement, segment.getText());
+        SubquerySegment result = new SubquerySegment(segment.getStartIndex(), 
segment.getStopIndex(), boundSelectStatement, segment.getText());
+        
selectBinderContext.getCommonTableExpressionsSegmentsUniqueAliases().forEach(each
 -> {
+            
ShardingSpherePreconditions.checkNotContains(binderContext.getCommonTableExpressionsSegmentsUniqueAliases(),
 each, () -> new UniqueCommonTableExpressionException(each.toString()));

Review Comment:
   I have changed the logic for UniqueCommonTableAlias check
   This check happens in MySQL  but in ShardingSphere this check was happening 
while the query is executed in MySQL database so I have added this check during 
the creation of Query Context.
   ![Screenshot 2024-12-31 
121634](https://github.com/user-attachments/assets/f922397b-5d3c-4b11-9fd2-7d00ce91313c)
   
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to