forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enchement](utf8)import enable_text_validate_utf8 session var (apache…
…#45537) Problem Summary: When reading text format files in Hive catalog and TVF, sometimes you may encounter the exception `Only support csv data in utf8 codec`. I introduced a new session variable `enable_text_validate_utf8` to control whether to check the utf8 format. Introduced `enable_text_validate_utf8` session variable to control whether to check the utf8 format.
- Loading branch information
Showing
11 changed files
with
222 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_scripts/run72.hql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
CREATE TABLE invalid_utf8_data ( | ||
id INT, | ||
corrupted_data STRING, | ||
string_data1 STRING, | ||
string_data2 STRING | ||
) | ||
ROW FORMAT DELIMITED | ||
FIELDS TERMINATED BY ',' | ||
LINES TERMINATED BY '\n' | ||
location '/user/doris/preinstalled_data/text/utf8_check'; | ||
|
||
|
||
CREATE TABLE invalid_utf8_data2 ( | ||
id INT, | ||
corrupted_data STRING, | ||
string_data1 STRING, | ||
string_data2 STRING | ||
) | ||
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' | ||
WITH SERDEPROPERTIES ( | ||
"separatorChar" = ",", | ||
"quoteChar" = "\"", | ||
"escapeChar" = "\\" | ||
) | ||
location '/user/doris/preinstalled_data/text/utf8_check'; | ||
msck repair table invalid_utf8_data; | ||
msck repair table invalid_utf8_data2; | ||
5 changes: 5 additions & 0 deletions
5
...parties/docker-compose/hive/scripts/preinstalled_data/text/utf8_check/utf8_check_fail.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
1,�,AAB,helloworld | ||
2,��,AAB,helloworld | ||
2,���,AAB,helloworld | ||
4,����,AAB,helloworld | ||
5,�����,AAB,helloworld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
regression-test/data/external_table_p0/hive/test_utf8_check.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !1 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
||
-- !2 -- | ||
c1 text Yes false \N NONE | ||
c2 text Yes false \N NONE | ||
c3 text Yes false \N NONE | ||
c4 text Yes false \N NONE | ||
|
||
-- !3 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
||
-- !4 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
||
-- !1 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
||
-- !2 -- | ||
c1 text Yes false \N NONE | ||
c2 text Yes false \N NONE | ||
c3 text Yes false \N NONE | ||
c4 text Yes false \N NONE | ||
|
||
-- !3 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
||
-- !4 -- | ||
1 � AAB helloworld | ||
2 �� AAB helloworld | ||
2 ��� AAB helloworld | ||
4 ���� AAB helloworld | ||
5 ����� AAB helloworld | ||
|
100 changes: 100 additions & 0 deletions
100
regression-test/suites/external_table_p0/hive/test_utf8_check.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// 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. | ||
|
||
|
||
suite("test_utf8_check","p0,external,tvf,hive,external_docker,external_docker_hive") { | ||
String enabled = context.config.otherConfigs.get("enableHiveTest") | ||
if (enabled == null || !enabled.equalsIgnoreCase("true")) { | ||
logger.info("diable Hive test.") | ||
return; | ||
} | ||
|
||
for (String hivePrefix : ["hive2","hive3"]) { | ||
|
||
String hms_port = context.config.otherConfigs.get(hivePrefix + "HmsPort") | ||
String catalog_name = "${hivePrefix}_test_utf8_check" | ||
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp") | ||
def hdfsUserName = "doris" | ||
String hdfs_port = context.config.otherConfigs.get(hivePrefix + "HdfsPort") | ||
def defaultFS = "hdfs://${externalEnvIp}:${hdfs_port}" | ||
|
||
sql """drop catalog if exists ${catalog_name}""" | ||
sql """create catalog if not exists ${catalog_name} properties ( | ||
"type"="hms", | ||
'hive.metastore.uris' = 'thrift://${externalEnvIp}:${hms_port}' | ||
);""" | ||
sql """use `${catalog_name}`.`default`""" | ||
|
||
|
||
sql """ set enable_text_validate_utf8 = true; """ | ||
|
||
test { | ||
sql """ select * from invalid_utf8_data """ | ||
exception """Only support csv data in utf8 codec""" | ||
} | ||
|
||
|
||
test { | ||
sql """ select * from invalid_utf8_data2; """ | ||
exception """Only support csv data in utf8 codec""" | ||
} | ||
|
||
|
||
def uri = "${defaultFS}" + "/user/doris/preinstalled_data/text/utf8_check/utf8_check_fail.csv" | ||
|
||
|
||
test { | ||
sql """ desc function HDFS( | ||
"uri" = "${uri}", | ||
"hadoop.username" = "${hdfsUserName}", | ||
"format" = "csv", | ||
"column_separator"=",")""" | ||
exception """Only support csv data in utf8 codec""" | ||
} | ||
|
||
test { | ||
sql """select * from HDFS( | ||
"uri" = "${uri}", | ||
"hadoop.username" = "${hdfsUserName}", | ||
"format" = "csv", | ||
"column_separator"=",")""" | ||
exception """Only support csv data in utf8 codec""" | ||
} | ||
|
||
|
||
sql """ set enable_text_validate_utf8 = false; """ | ||
|
||
qt_1 """select * from invalid_utf8_data order by id """ | ||
|
||
qt_2 """ desc function HDFS( | ||
"uri" = "${uri}", | ||
"hadoop.username" = "${hdfsUserName}", | ||
"format" = "csv", | ||
"column_separator"=",")""" | ||
|
||
|
||
qt_3 """select * from HDFS( | ||
"uri" = "${uri}", | ||
"hadoop.username" = "${hdfsUserName}", | ||
"format" = "csv", | ||
"column_separator"=",") order by c1""" | ||
qt_4 """select * from invalid_utf8_data2 order by id """ | ||
|
||
|
||
} | ||
|
||
} |