strongduanmu commented on code in PR #34384:
URL: https://github.com/apache/shardingsphere/pull/34384#discussion_r1925126292
##########
infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/with/CommonTableExpressionSegmentBinder.java:
##########
@@ -66,4 +67,14 @@ public static CommonTableExpressionSegment bind(final
CommonTableExpressionSegme
result.getColumns().addAll(segment.getColumns());
Review Comment:
Please check it again, these columns need call ColumnSegmentBinder
##########
test/it/binder/src/test/resources/cases/dml/select.xml:
##########
@@ -478,6 +478,151 @@
</projections>
</select>
+ <select sql-case-id="select_with_with_clause_with_column_definition">
+ <with start-index="0" stop-index="81">
+ <common-table-expression name="t_order_tmp" start-index="5"
stop-index="81">
+ <subquery-expression start-index="5" stop-index="81">
+ <select>
+ <projections start-index="65" stop-index="65">
+ <shorthand-projection start-index="65"
stop-index="65">
+ <actual-projections>
+ <column-projection name="order_id"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="order_id"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ <column-projection name="user_id"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="user_id"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ <column-projection name="status"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="status"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ <column-projection name="merchant_id"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column
name="merchant_id" start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ <column-projection name="remark"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="remark"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ <column-projection name="creation_date"
start-index="0" stop-index="0" start-delimiter="`" end-delimiter="`">
+ <owner name="o" start-index="0"
stop-index="0" />
+ <column-bound>
+ <original-database name="foo_db_1"
/>
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column
name="creation_date" start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column-projection>
+ </actual-projections>
+ </shorthand-projection>
+ </projections>
+ <from>
+ <simple-table name="t_order" alias="o"
start-index="72" stop-index="80">
+ <table-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ </table-bound>
+ </simple-table>
+ </from>
+ </select>
+ </subquery-expression>
+ <column name="col1" start-index="18" stop-index="21">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="order_id" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column>
+ <column name="col2" start-index="24" stop-index="27">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="user_id" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column>
+ <column name="col3" start-index="30" stop-index="33">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="status" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column>
+ <column name="col4" start-index="36" stop-index="39">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="merchant_id"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column>
+ <column name="col5" start-index="42" stop-index="45">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="remark" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column>
+ <column name="col6" start-index="48" stop-index="51">
Review Comment:
Can you check SQLStatementAssert to confirm whether these columns have been
asserted?
--
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]