hawk9821 opened a new issue, #9026:
URL: https://github.com/apache/seatunnel/issues/9026

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   Openguass upsert throw exption When a table has a unique index
   
   ddl :
   
   ```
   CREATE TABLE test.st_test (
        id int8 NOT NULL,
        id_card varchar NULL,
        "name" varchar NULL,
        CONSTRAINT st_test_pk PRIMARY KEY (id),
        CONSTRAINT st_test_unique UNIQUE (id_card)
   )
   ```
   
   ### SeaTunnel Version
   
   dev
   
   ### SeaTunnel Config
   
   ```conf
   #
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   #     http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   #
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   #     http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   env {
     parallelism = 1
     job.mode = "BATCH"
   }
   
   source {
     jdbc {
       url = 
"jdbc:opengauss://192.168.220.98:54328/xxx?loggerLevel=OFF&stringtype=unspecified"
       driver = "org.opengauss.Driver"
       connection_check_timeout_sec = 100
       user = "******"
       password = "******"
       database = "xxx"
       table_list = [
         {table_path="xxx.test.st_test"}
       ]
       split.size = 5000
     }
   }
   
   transform {
   }
   
   sink {
     jdbc {
       url = 
"jdbc:opengauss://192.168.220.98:54328/xxx?loggerLevel=OFF&stringtype=unspecified"
       driver = "org.opengauss.Driver"
       connection_check_timeout_sec = 100
       user = "******"
       password = "*******"
       database = "xxx"
       table = "test.st_test2"
       generate_sink_sql = true
     }
   }
   ```
   
   ### Running Command
   
   ```shell
   seatunnel.sh --config openguass_to_openguass.conf
   ```
   
   ### Error Exception
   
   ```log
   Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO 
"qmjk"."test"."st_test2" ("id", "id_card", "name") VALUES ('1', '1', '2') ON 
DUPLICATE KEY UPDATE "id_card"=EXCLUDED."id_card", "name"=EXCLUDED."name" was 
aborted: [192.168.220.98:54328] ERROR: INSERT ON DUPLICATE KEY UPDATE don't 
allow update on primary key or unique key.  Call getNextException to see other 
errors in the batch.
        at 
org.opengauss.jdbc.BatchResultHandler.handleCompletion(BatchResultHandler.java:173)
        at 
org.opengauss.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:1007)
        at org.opengauss.jdbc.PgStatement.executeBatch(PgStatement.java:1098)
        at 
org.opengauss.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1661)
        at 
com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:127)
        at 
com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
        at 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.executor.FieldNamedPreparedStatement.executeBatch(FieldNamedPreparedStatement.java:540)
        at 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.executor.SimpleBatchStatementExecutor.executeBatch(SimpleBatchStatementExecutor.java:54)
        at 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.executor.BufferReducedBatchStatementExecutor.executeBatch(BufferReducedBatchStatementExecutor.java:89)
        at 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.JdbcOutputFormat.attemptFlush(JdbcOutputFormat.java:172)
        at 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:136)
        ... 9 more
   Caused by: org.opengauss.util.PSQLException: 
[192.168.230.198:62498/10.8.85.37:15400] ERROR: INSERT ON DUPLICATE KEY UPDATE 
don't allow update on primary key or unique key.
        at 
org.opengauss.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2922)
        at 
org.opengauss.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2643)
        at 
org.opengauss.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:375)
        at 
org.opengauss.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:1003)
        ... 18 more
   ```
   
   ### Zeta or Flink or Spark Version
   
   zeta
   
   ### Java or Scala Version
   
   1.8
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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-unsubscr...@seatunnel.apache.org.apache.org

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

Reply via email to