You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "hawk9821 (via GitHub)" <gi...@apache.org> on 2024/09/24 01:57:46 UTC

[PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

hawk9821 opened a new pull request, #7728:
URL: https://github.com/apache/seatunnel/pull/7728

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   Dynamic bucket allocation did not take into account that the primary key was not in the first place, resulting in an error when executing the loadBucketIndex method in the initialization of the PaimonBucketAssigner class .  This pr fixed the problem
    
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   PaimonSinkDynamicBucketIT#primaryFullTypeAndLoadData
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772481632


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +163,22 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {
+            if (e.getCause() instanceof UnsupportedOperationException) {

Review Comment:
   If it throw a UnsupportedOperationException, it's must be a Paimon primary key datatype is unsupported?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][Connecotr-V2] Fix paimon dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1774363133


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/config/PaimonSinkConfig.java:
##########
@@ -77,5 +79,12 @@ public PaimonSinkConfig(ReadonlyConfig readonlyConfig) {
         this.primaryKeys = stringToList(readonlyConfig.get(PRIMARY_KEYS), ",");
         this.partitionKeys = stringToList(readonlyConfig.get(PARTITION_KEYS), ",");
         this.writeProps = readonlyConfig.get(WRITE_PROPS);
+        checkConfig();
+    }
+
+    private void checkConfig() {
+        if (this.primaryKeys.isEmpty() && "-1".equals(this.writeProps.get("bucket"))) {

Review Comment:
   There's something wrong with this, because if you created the table manually instead of automatically, there's no default value for writeProps.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][Connecotr-V2] Fix paimon dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1774420306


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/config/PaimonSinkConfig.java:
##########
@@ -77,5 +79,12 @@ public PaimonSinkConfig(ReadonlyConfig readonlyConfig) {
         this.primaryKeys = stringToList(readonlyConfig.get(PRIMARY_KEYS), ",");
         this.partitionKeys = stringToList(readonlyConfig.get(PARTITION_KEYS), ",");
         this.writeProps = readonlyConfig.get(WRITE_PROPS);
+        checkConfig();
+    }
+
+    private void checkConfig() {
+        if (this.primaryKeys.isEmpty() && "-1".equals(this.writeProps.get("bucket"))) {

Review Comment:
   So this is just a warning .   Manually created tables should be PaimonSinkWriter initialized with a warning



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][Connecotr-V2] Fix paimon dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1774360933


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +164,25 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {

Review Comment:
   The suggestion is to extract a method to handle the exception, which is weird and not very readable.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772481632


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +163,22 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {
+            if (e.getCause() instanceof UnsupportedOperationException) {

Review Comment:
   If there throw a UnsupportedOperationException, it's must be a Paimon primary key datatype is unsupported?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#issuecomment-2369988400

   cc @dailai 


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1773011363


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {

Review Comment:
   Dynamic bucket splitting currently supports only the primary key table, not the append only table,  append only table ' s bucketMode is UNAWARE, dynamic bucket splitting logic is not executed. 



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1773010917


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +163,22 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {
+            if (e.getCause() instanceof UnsupportedOperationException) {

Review Comment:
   Added pattern matching 



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1773009678


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +163,22 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {

Review Comment:
   add UT PaimonCatalogTest



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772492176


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {
+                    String name = primaryKeys.get(i).name();
+                    DataType type = primaryKeys.get(i).type();
+                    binaryRow.setField(
+                            fieldIndexMap.get(name), getPrimaryFieldValue(row, i, type, name));

Review Comment:
   You are no need define the method named getPrimaryFiledValue. You can use it like this InternalRow.createFieldGetter(type,i).getFieldOrNull(binaryRow);



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772492920


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {
+                    String name = primaryKeys.get(i).name();
+                    DataType type = primaryKeys.get(i).type();
+                    binaryRow.setField(
+                            fieldIndexMap.get(name), getPrimaryFieldValue(row, i, type, name));

Review Comment:
   Otherwise the primary key  of paimon support all data types? 



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772480537


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -161,6 +163,22 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI
             throw new TableAlreadyExistException(this.catalogName, tablePath);
         } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {
             throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());
+        } catch (Exception e) {

Review Comment:
   Please add UT a cover this case.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][Connecotr-V2] Fix paimon dynamic bucket tale in primary key is not first [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1774657957


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/config/PaimonSinkConfig.java:
##########
@@ -77,5 +79,12 @@ public PaimonSinkConfig(ReadonlyConfig readonlyConfig) {
         this.primaryKeys = stringToList(readonlyConfig.get(PRIMARY_KEYS), ",");
         this.partitionKeys = stringToList(readonlyConfig.get(PARTITION_KEYS), ",");
         this.writeProps = readonlyConfig.get(WRITE_PROPS);
+        checkConfig();
+    }
+
+    private void checkConfig() {
+        if (this.primaryKeys.isEmpty() && "-1".equals(this.writeProps.get("bucket"))) {
+            log.warn("Append only table currently do not support dynamic bucket");

Review Comment:
   Add msg : `rollback to ???`



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772491445


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {

Review Comment:
   get



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772489045


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {

Review Comment:
   How about have no primary keys? Can you add this e2e case ?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1772491445


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {

Review Comment:
   get



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][CONNECTORS-V2] fix dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728#discussion_r1773011658


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonBucketAssigner.java:
##########
@@ -59,27 +65,85 @@ public PaimonBucketAssigner(Table table, int numAssigners, int assignId) {
 
     private void loadBucketIndex(FileStoreTable fileStoreTable, int numAssigners, int assignId) {
         IndexBootstrap indexBootstrap = new IndexBootstrap(fileStoreTable);
+        List<String> fieldNames = schema.fieldNames();
+        Map<String, Integer> fieldIndexMap =
+                IntStream.range(0, fieldNames.size())
+                        .boxed()
+                        .collect(Collectors.toMap(fieldNames::get, Function.identity()));
+        List<DataField> primaryKeys = schema.primaryKeysFields();
         try (RecordReader<InternalRow> recordReader =
                 indexBootstrap.bootstrap(numAssigners, assignId)) {
             RecordReaderIterator<InternalRow> readerIterator =
                     new RecordReaderIterator<>(recordReader);
             while (readerIterator.hasNext()) {
                 InternalRow row = readerIterator.next();
-                assign(row);
+                GenericRow binaryRow = new GenericRow(fieldNames.size());
+                for (int i = 0; i < primaryKeys.size(); i++) {
+                    String name = primaryKeys.get(i).name();
+                    DataType type = primaryKeys.get(i).type();
+                    binaryRow.setField(
+                            fieldIndexMap.get(name), getPrimaryFieldValue(row, i, type, name));

Review Comment:
   get 



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][Connecotr-V2] Fix paimon dynamic bucket tale in primary key is not first [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 merged PR #7728:
URL: https://github.com/apache/seatunnel/pull/7728


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org