-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column bind update in with segment bind #34384
base: master
Are you sure you want to change the base?
Column bind update in with segment bind #34384
Conversation
Hi @Yash-cor, can you update release note? |
Yes Sir |
Hello @strongduanmu I have updated the release notes. |
…nto COLUMN_BIND_IN_WITH_SEGMENT_BIND Resolve Release Notes Merge Conflict.
…' into COLUMN_BIND_IN_WITH_SEGMENT_BIND
return new SimpleTableSegmentBinderContext(commonTableExpressionSegment.getSubquery().getSelect().getProjections().getProjections()); | ||
} else { | ||
Collection<ProjectionSegment> projectionSegments = new LinkedList<>(); | ||
commonTableExpressionSegment.getColumns().forEach(each -> projectionSegments.add(new ColumnProjectionSegment(each))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this logic to CommonTableExpressionSegmentBinder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @strongduanmu while changing the logic I found Error in the way WithSegment is handling Recursive segment of with clause.
-
Recursive segment allows user to use the same common table expression ( cte ) name in cte's subquery
Example -WITH RECURSIVE cte AS ( SELECT 1 as (n) UNION ALL SELECT n + 1 FROM cte WHERE n < 5 ) SELECT * FROM cte;
or similarly can be written as
WITH RECURSIVE cte (n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 5 ) SELECT * FROM cte;
-
The WITH clause must begin with WITH RECURSIVE if any CTE in the WITH clause refers to itself. (If no CTE refers to itself, RECURSIVE is permitted but not required.) We have to include a check for it.
-
The recursive CTE subquery has two parts, separated by UNION ALL or UNION DISTINCT. Thus, a recursive CTE consists of a non-recursive SELECT part followed by a recursive SELECT part. Should i include a check for it as this check happens when the query hits the MySQL database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this logic to CommonTableExpressionSegmentBinder?
I have added this logic in CommonTableExpressionSegmentBinder inside the recursion condition.
</from> | ||
</select> | ||
</subquery-expression> | ||
<column name="col1" start-index="18" stop-index="21"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add column-bound
expected result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the column-bound info
@@ -66,4 +67,14 @@ public static CommonTableExpressionSegment bind(final CommonTableExpressionSegme | |||
result.getColumns().addAll(segment.getColumns()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check it again, these columns need call ColumnSegmentBinder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes help in ColumnSegmentBind
<original-column name="remark" start-delimiter="`" end-delimiter="`" /> | ||
</column-bound> | ||
</column> | ||
<column name="col6" start-index="48" stop-index="51"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check SQLStatementAssert to confirm whether these columns have been asserted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have checked these asserts.
…ion segment from WithSegmentBinder to CommonTableExpressionBinder.
…/Yash-cor/shardingsphere into COLUMN_BIND_IN_WITH_SEGMENT_BIND Resolves Merge Conflict in Release Notes.
…nto COLUMN_BIND_IN_WITH_SEGMENT_BIND
Fixes #ISSUSE_ID.
Changes proposed in this pull request:
Added DifferenceInColumnCountOfSelectListAndColumnNameListException to handle difference in Column counts.
While using With Clause when Column definition is added it caused Column not found exception.
Made correction in column bind and externalTableBinderContext in CommonTableExpressionBinder.
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.