SEPURI-SAI-KRISHNA opened a new issue, #13388:
URL: https://github.com/apache/seatunnel/issues/13388

   ### 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. This is the separate issue promised in #13188 and 
#13190, which fixed the same driver error for `TIME` only.
   
   ### What happened
   
   Outside CDC mode, a Databend sink job with a `TIMESTAMP` column fails at the 
first row.
   
   `DatabendSinkWriter.processRow` passes each value to 
`PreparedStatement.setObject`. Since #13190 it writes a `java.time.LocalTime` 
as text, but a `TIMESTAMP` value is a `java.time.LocalDateTime`, and 
databend-jdbc 0.3.7 rejects it. In the driver, 
`DatabendPreparedStatement.setObject` handles `Boolean`, the number types, 
`BigDecimal`, `String`, `byte[]`, `java.sql.Date`, `LocalDate`, 
`java.sql.Time`, `OffsetTime`, `java.sql.Timestamp`, `Map`, `Array` and 
`ArrayList`, and throws for anything else:
   
   ```
   SQLException: Unsupported object type: java.time.LocalDateTime
   ```
   
   The table itself is created correctly: `DatabendCatalog` maps `TIMESTAMP` to 
`TIMESTAMP`. Only the write fails. CDC mode is not affected by this error, 
because it writes the rows as JSON text.
   
   No E2E in `connector-databend-e2e` writes a `TIMESTAMP` value through the 
sink, which is why this was not caught.
   
   I would like to submit a PR that writes a `LocalDateTime` as text, as #13190 
does for `LocalTime`.
   
   ### SeaTunnel Version
   
   dev (7029c0969a)
   
   ### SeaTunnel Config
   
   ```conf
   env {
     parallelism = 1
     job.mode = "BATCH"
   }
   
   source {
     FakeSource {
       schema {
         fields {
           id = int
           created_at = timestamp
         }
       }
       rows = [
         { kind = INSERT, fields = [1, "2024-03-10T10:00:00"] }
       ]
     }
   }
   
   sink {
     Databend {
       url = "jdbc:databend://localhost:8000/default"
       username = "root"
       password = ""
       database = "default"
       table = "timestamp_sink_table"
       schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"
       data_save_mode = "APPEND_DATA"
     }
   }
   ```
   
   ### Running Command
   
   ```shell
   ./bin/seatunnel.sh --config fake_timestamp_to_databend.conf
   ```
   
   I ran it in the Zeta E2E container of `connector-databend-e2e`, against the 
Databend image the E2E uses.
   
   ### Error Exception
   
   ```log
   
org.apache.seatunnel.connectors.seatunnel.databend.exception.DatabendConnectorException:
 ErrorCode:[DATABEND-02], ErrorDescription:[Failed to execute SQL in Databend] 
- Failed to write data to Databend: Unsupported object type: 
java.time.LocalDateTime
        at 
org.apache.seatunnel.connectors.seatunnel.databend.sink.DatabendSinkWriter.write(DatabendSinkWriter.java:378)
        ...
   Caused by: java.sql.SQLException: Unsupported object type: 
java.time.LocalDateTime
        at 
com.databend.jdbc.DatabendPreparedStatement.setObject(DatabendPreparedStatement.java:735)
        at 
org.apache.seatunnel.connectors.seatunnel.databend.sink.DatabendSinkWriter.processRow(DatabendSinkWriter.java:696)
        at 
org.apache.seatunnel.connectors.seatunnel.databend.sink.DatabendSinkWriter.processTraditionalRow(DatabendSinkWriter.java:456)
        at 
org.apache.seatunnel.connectors.seatunnel.databend.sink.DatabendSinkWriter.write(DatabendSinkWriter.java:354)
        at 
org.apache.seatunnel.engine.server.task.flow.SinkFlowLifeCycle.processDataRecord(SinkFlowLifeCycle.java:574)
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta (dev), run through the E2E `TestContainer` with the config above. The 
write path is the same on every engine.
   
   ### Java or Scala Version
   
   JDK 11 (the Zeta E2E container)
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to