Hisoka-X commented on code in PR #9607:
URL: https://github.com/apache/seatunnel/pull/9607#discussion_r2222443762


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/vertica/VerticaDialect.java:
##########
@@ -53,16 +54,35 @@ public String quoteIdentifier(String identifier) {
     @Override
     public Optional<String> getUpsertStatement(
             String database, String tableName, String[] fieldNames, String[] 
uniqueKeyFields) {
+        return Optional.empty();
+    }
+
+    @Override
+    public Optional<String> getUpsertStatementByTableSchema(
+            String database, String tableName, TableSchema tableSchema, 
String[] uniqueKeyFields) {
+        String[] fieldNames = tableSchema.getFieldNames();
         List<String> nonUniqueKeyFields =
                 Arrays.stream(fieldNames)
                         .filter(fieldName -> 
!Arrays.asList(uniqueKeyFields).contains(fieldName))
                         .collect(Collectors.toList());
         String valuesBinding =
-                Arrays.stream(fieldNames)
-                        .map(fieldName -> ":" + fieldName + " " + 
quoteIdentifier(fieldName))
+                tableSchema.getColumns().stream()
+                        .map(
+                                column -> {
+                                    String fieldName = column.getName();
+                                    String sourceType = column.getSourceType();
+                                    return "CAST("
+                                            + ":"
+                                            + fieldName
+                                            + " AS "
+                                            + sourceType
+                                            + ")"
+                                            + " AS "
+                                            + quoteIdentifier(fieldName);

Review Comment:
   why we must add cast as statement? Is it necessary to fix `[Vertica]VJDBC 
ERROR: Failed to find conversion function from unknown to in`?



-- 
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]

Reply via email to