sandynz commented on code in PR #20966:
URL: https://github.com/apache/shardingsphere/pull/20966#discussion_r970302258
##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverter.java:
##########
@@ -125,9 +125,9 @@ private DataRecord createDataRecord(final AbstractRowEvent
rowsEvent, final int
private void putColumnsIntoDataRecord(final DataRecord dataRecord, final
PipelineTableMetaData tableMetaData, final List<Object> values) {
for (int i = 0, count = values.size(); i < count; i++) {
- boolean isUniqueKey = tableMetaData.isUniqueKey(i);
+ boolean isUniqueKey = tableMetaData.isUniqueKey(i + 1);
Object uniqueKeyOldValue = isUniqueKey ? values.get(i) : null;
- Column column = new
Column(tableMetaData.getColumnMetaData(i).getName(), uniqueKeyOldValue,
values.get(i), true, isUniqueKey);
+ Column column = new Column(tableMetaData.getColumnMetaData(i +
1).getName(), uniqueKeyOldValue, values.get(i), true, isUniqueKey);
Review Comment:
It could be simplified after move `uniqueKey` to `PipelineColumnMetaData`.
Get column metadata firstly, then check whether it's unique key or not.
##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/metadata/model/PipelineTableMetaData.java:
##########
@@ -89,14 +89,14 @@ public PipelineColumnMetaData getColumnMetaData(final
String columnName) {
/**
* Judge whether column is unique key or not.
*
- * @param columnIndex column index
+ * @param columnIndex the first column is 1, the second is 2, ...
* @return true if the column is unique key, otherwise false
*/
public boolean isUniqueKey(final int columnIndex) {
- if (columnIndex >= columnNames.size()) {
+ if (columnIndex > columnNames.size()) {
return false;
}
Review Comment:
1, Could we add `uniqueKey` in `PipelineColumnMetaData`? It might could
replace `primaryKey`.
2, Could we remove `isUniqueKey` method in `PipelineTableMetaData`?
--
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]