Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
c6649979
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c6649979
编写于
2月 02, 2021
作者:
V
Vitaly Baranov
提交者:
GitHub
2月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19655 from ClickHouse/backport/20.12/18124
Backport #18124 to 20.12: fix issue #18086
上级
54c7753b
217aa468
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
10 deletion
+60
-10
src/DataTypes/convertMySQLDataType.cpp
src/DataTypes/convertMySQLDataType.cpp
+8
-3
tests/integration/test_mysql_database_engine/test.py
tests/integration/test_mysql_database_engine/test.py
+52
-7
未找到文件。
src/DataTypes/convertMySQLDataType.cpp
浏览文件 @
c6649979
...
...
@@ -38,10 +38,15 @@ DataTypePtr convertMySQLDataType(MultiEnum<MySQLDataTypesSupport> type_support,
size_t
precision
,
size_t
scale
)
{
// we expect mysql_data_type to be either "basic_type" or "type_with_params(param1, param2, ...)"
// Mysql returns mysql_data_type as below:
// 1. basic_type
// 2. basic_type options
// 3. type_with_params(param1, param2, ...)
// 4. type_with_params(param1, param2, ...) options
// The options can be unsigned, zerofill, or some other strings.
auto
data_type
=
std
::
string_view
(
mysql_data_type
);
const
auto
param_start_pos
=
data_type
.
find
(
'('
);
const
auto
type_name
=
data_type
.
substr
(
0
,
param_start
_pos
);
const
auto
type_end_pos
=
data_type
.
find_first_of
(
"(
\x20
"
);
// FIXME: fix style-check script instead
const
auto
type_name
=
data_type
.
substr
(
0
,
type_end
_pos
);
DataTypePtr
res
;
...
...
tests/integration/test_mysql_database_engine/test.py
浏览文件 @
c6649979
...
...
@@ -193,13 +193,59 @@ def test_data_types_support_level_for_mysql_database_engine(started_cluster):
mysql_node
.
query
(
"DROP DATABASE test"
)
decimal_values
=
[
0.123
,
0.4
,
5.67
,
8.91011
,
123456789.123
,
-
0.123
,
-
0.4
,
-
5.67
,
-
8.91011
,
-
123456789.123
]
timestamp_values
=
[
'2015-05-18 07:40:01.123'
,
'2019-09-16 19:20:11.123'
]
timestamp_values_no_subsecond
=
[
'2015-05-18 07:40:01'
,
'2019-09-16 19:20:11'
]
# test tool cannot support null by now. TSV format returns \N for null, so cannot compare using == directly
# float_values = ['NULL']
# float_values = [0] mysql returns 0 while clickhouse returns 0.0, so cannot compare using == directly
int32_values
=
[
0
,
1
,
-
1
,
2147483647
,
-
2147483648
]
uint32_values
=
[
0
,
1
]
# [FIXME] seems client have issue with value 4294967295, it returns -1 for it
mint_values
=
[
0
,
1
,
-
1
,
8388607
,
-
8388608
]
umint_values
=
[
0
,
1
,
16777215
]
int16_values
=
[
0
,
1
,
-
1
,
32767
,
-
32768
]
uint16_values
=
[
0
,
1
,
65535
]
int8_values
=
[
0
,
1
,
-
1
,
127
,
-
128
]
uint8_values
=
[
0
,
1
,
255
]
# string_values = ["'ClickHouse'", 'NULL']
string_values
=
[
"'ClickHouse'"
]
decimal_values
=
[
0
,
0.123
,
0.4
,
5.67
,
8.91011
,
123456789.123
,
-
0.123
,
-
0.4
,
-
5.67
,
-
8.91011
,
-
123456789.123
]
timestamp_values
=
[
"'2015-05-18 07:40:01.123'"
,
"'2019-09-16 19:20:11.123'"
]
timestamp_values_no_subsecond
=
[
"'2015-05-18 07:40:01'"
,
"'2019-09-16 19:20:11'"
]
@
pytest
.
mark
.
parametrize
(
"case_name, mysql_type, expected_ch_type, mysql_values, setting_mysql_datatypes_support_level"
,
[
# test common type mapping
# ("common_types", "FLOAT", "Nullable(Float32)", float_values, ""),
# ("common_types", "FLOAT UNSIGNED", "Nullable(Float32)", float_values, ""),
(
"common_types"
,
"INT"
,
"Nullable(Int32)"
,
int32_values
,
""
),
(
"common_types"
,
"INT NOT NULL"
,
"Int32"
,
int32_values
,
""
),
(
"common_types"
,
"INT UNSIGNED NOT NULL"
,
"UInt32"
,
uint32_values
,
""
),
(
"common_types"
,
"INT UNSIGNED"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INT UNSIGNED DEFAULT NULL"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INT UNSIGNED DEFAULT '1'"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INT(10)"
,
"Nullable(Int32)"
,
int32_values
,
""
),
(
"common_types"
,
"INT(10) NOT NULL"
,
"Int32"
,
int32_values
,
""
),
(
"common_types"
,
"INT(10) UNSIGNED NOT NULL"
,
"UInt32"
,
uint32_values
,
""
),
(
"common_types"
,
"INT(10) UNSIGNED"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INT(10) UNSIGNED DEFAULT NULL"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INT(10) UNSIGNED DEFAULT '1'"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"INTEGER"
,
"Nullable(Int32)"
,
int32_values
,
""
),
(
"common_types"
,
"INTEGER UNSIGNED"
,
"Nullable(UInt32)"
,
uint32_values
,
""
),
(
"common_types"
,
"MEDIUMINT"
,
"Nullable(Int32)"
,
mint_values
,
""
),
(
"common_types"
,
"MEDIUMINT UNSIGNED"
,
"Nullable(UInt32)"
,
umint_values
,
""
),
(
"common_types"
,
"SMALLINT"
,
"Nullable(Int16)"
,
int16_values
,
""
),
(
"common_types"
,
"SMALLINT UNSIGNED"
,
"Nullable(UInt16)"
,
uint16_values
,
""
),
(
"common_types"
,
"TINYINT"
,
"Nullable(Int8)"
,
int8_values
,
""
),
(
"common_types"
,
"TINYINT UNSIGNED"
,
"Nullable(UInt8)"
,
uint8_values
,
""
),
(
"common_types"
,
"VARCHAR(10)"
,
"Nullable(String)"
,
string_values
,
""
),
(
"decimal_default"
,
"decimal NOT NULL"
,
"Decimal(10, 0)"
,
decimal_values
,
"decimal,datetime64"
),
(
"decimal_default_nullable"
,
"decimal"
,
"Nullable(Decimal(10, 0))"
,
decimal_values
,
...
...
@@ -220,9 +266,8 @@ timestamp_values_no_subsecond = ['2015-05-18 07:40:01', '2019-09-16 19:20:11']
"decimal,datetime64"
),
# right now precision bigger than 39 is not supported by ClickHouse's Decimal, hence fall back to String
(
"decimal_40_6"
,
"decimal(40, 6) NOT NULL"
,
"String"
,
decimal_values
,
"decimal,datetime64"
),
(
"decimal_40_6"
,
"decimal(40, 6) NOT NULL"
,
"String"
,
decimal_values
,
"decimal,datetime64"
),
(
"decimal_18_6"
,
"decimal(18, 6) NOT NULL"
,
"String"
,
decimal_values
,
"datetime64"
),
(
"decimal_18_6"
,
"decimal(18, 6) NOT NULL"
,
"String"
,
decimal_values
,
""
),
(
"datetime_6"
,
"DATETIME(6) NOT NULL"
,
"DateTime"
,
timestamp_values_no_subsecond
,
...
...
@@ -240,7 +285,7 @@ def test_mysql_types(started_cluster, case_name, mysql_type, expected_ch_type, m
mysql_db
=
'decimal_support'
,
table_name
=
case_name
,
mysql_type
=
mysql_type
,
mysql_values
=
', '
.
join
(
'({})'
.
format
(
repr
(
x
)
)
for
x
in
mysql_values
),
mysql_values
=
', '
.
join
(
'({})'
.
format
(
x
)
for
x
in
mysql_values
),
ch_mysql_db
=
'mysql_db'
,
ch_mysql_table
=
'mysql_table_engine_'
+
case_name
,
expected_ch_type
=
expected_ch_type
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录