seatunnel icon indicating copy to clipboard operation
seatunnel copied to clipboard

[Bug] [spark-jdbc-connector] mysql emoji insert error

Open rekichan opened this issue 2 years ago • 1 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

What happened

In my case,my data is from hive to mysql and the data-row has some emoji characters. And my mysql database and table charset has been changed to utf8mb4. How can i correctly configuare the *.config to modify the charset, and then prevent following excepetion? thx.

ex: Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x95\xB6\xEF\xB8...' for column 'rowname' at row 1

SeaTunnel Version

2.1.3

SeaTunnel Config

env {
    spark.app.name = "app_name"
    spark.executor.instances = 5
    spark.executor.cores = 3
    spark.executor.memory = "4g"
    spark.driver.memory = "1g"
    spark.sql.catalogImplementation = "hive"
    spark.sql.shuffle.partitions = 200
}

source {
    hive {
      pre_sql = "my sql",
      result_table_name = "tmp_tbl"
    }
}

transform {

}

sink {
    jdbc{
      driver = "com.mysql.jdbc.Driver"
      url = "jdbc:mysql://myhost:3306/mydb"
      user = "u"
      password = "p"
      dbTable = "target"
      saveMode = "overwrite"
      batchsize = "5000"
    }
}

Running Command

/opt/seatunnel-2.1.3/bin/start-seatunnel-spark.sh \
  --master yarn \
  --deploy-mode cluster \
  --config ./a.config

Error Exception

Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x95\xB6\xEF\xB8...' for column 'rowname' at row 1

Zeta or Flink or Spark Version

spark 2.4.8-2.11

Java or Scala Version

No response

Screenshots

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

rekichan avatar Feb 18 '24 09:02 rekichan

This issue has been solved.We can try to use binary(row-data) to deal with charset problem.

rekichan avatar Feb 19 '24 08:02 rekichan