Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [Zeta] Synchronize data from MySQL to Hive Chinese field garbled code #5244

Closed
2 of 3 tasks
chuansenwang opened this issue Aug 8, 2023 · 6 comments
Closed
2 of 3 tasks

Comments

@chuansenwang
Copy link

chuansenwang commented Aug 8, 2023

Search before asking

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

What happened

I deployed a seatunnel cluster using a container and attempted to synchronize data from the MySQL database to the Hive warehouse. However, I found that the Hive Chinese fields were garbled during the query

MySQL database query display
123 张三 10
124 李四 10

Hive database query display
123,??,10
124,??,10

The data I insert through commands on the console will not be garbled
INSERT INTO student VALUES (1234,"哈哈2",12);

Hive database query display
123,??,10
124,??,10
1234,"哈哈2",12

SeaTunnel Version

seatunnel 2.3.2
mysql 5.7
hive 3.1.3
hadoop 3.3.5
jdk 1.8

SeaTunnel Config

env {
  job.name = "test_mysql_source_to_hive"
  execution.parallelism = 1
  job.mode = "BATCH"
}
source{
    jdbc {
        url = "jdbc:mysql://mysql-master:3306/test?serverTimezone=GMT%2b8&characterEncoding=utf-8"
        #driver = "com.mysql.cj.jdbc.Driver"
        driver = "com.mysql.jdbc.Driver"
        connection_check_timeout_sec = 100
        user = "root"
        password = "123456"
        query = "select id,name,age from student"
    }
}

transform {
    # If you would like to get more information about how to configure seatunnel and see full list of transform plugins,
    # please go to https://seatunnel.apache.org/docs/transform/sql
}

sink {
    Hive {
        table_name = "default.student"
        metastore_uri = "thrift://hive-metastore:9083"
  }
}

Running Command

$SEATUNNEL_HOME/bin/seatunnel.sh --config $SEATUNNEL_HOME/config/MySQL2Hive.conf

Error Exception

Zeta or Flink or Spark Version

No response

Java or Scala Version

jdk 1.8

Screenshots

创建Hive语句
CREATE TABLE IF NOT EXISTS student(
id INT COMMENT 'ID',
name STRING COMMENT '名字',
age INT COMMENT '年龄'
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';

MySQL 数据库语句:
CREATE TABLE Student (
id bigint(20) NOT NULL,
name varchar(255) DEFAULT NULL,
age int(2) DEFAULT NULL,
sex tinyint(1) DEFAULT NULL,
address varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@chuansenwang chuansenwang changed the title [Bug] [Zeta] 从MySQL同步数据到Hive中文字段乱码 [Bug] [Zeta] Synchronize data from MySQL to Hive Chinese field garbled code Aug 8, 2023
@zhilinli123
Copy link
Contributor

Do you get garbled characters when you insert into xx in hive?

@chuansenwang
Copy link
Author

Do you get garbled characters when you insert into xx in hive?

thank you for your reply. when I insert into xxx in Hive, it won't garble.
and when I use Spark3 Engine to execute the same task, it won't garble
image

@zhilinli123
Copy link
Contributor

I will try to fix it!

@zhilinli123
Copy link
Contributor

Can you provide your hive ddl @chuansenwang

@github-actions
Copy link

github-actions bot commented Sep 9, 2023

This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

@github-actions github-actions bot added the stale label Sep 9, 2023
@github-actions
Copy link

This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants