Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
720f8667
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,发现更多精彩内容 >>
提交
720f8667
编写于
5月 15, 2019
作者:
C
chertus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix decimal quoted csv input
上级
98359a6a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
4 deletion
+53
-4
dbms/src/DataTypes/DataTypesDecimal.cpp
dbms/src/DataTypes/DataTypesDecimal.cpp
+12
-2
dbms/src/DataTypes/DataTypesDecimal.h
dbms/src/DataTypes/DataTypesDecimal.h
+3
-2
dbms/src/IO/readFloatText.h
dbms/src/IO/readFloatText.h
+16
-0
dbms/tests/queries/0_stateless/00861_decimal_quoted_csv.reference
...ts/queries/0_stateless/00861_decimal_quoted_csv.reference
+5
-0
dbms/tests/queries/0_stateless/00861_decimal_quoted_csv.sql
dbms/tests/queries/0_stateless/00861_decimal_quoted_csv.sql
+17
-0
未找到文件。
dbms/src/DataTypes/DataTypesDecimal.cpp
浏览文件 @
720f8667
...
...
@@ -52,10 +52,13 @@ void DataTypeDecimal<T>::serializeText(const IColumn & column, size_t row_num, W
}
template
<
typename
T
>
void
DataTypeDecimal
<
T
>::
readText
(
T
&
x
,
ReadBuffer
&
istr
,
UInt32
precision
,
UInt32
scale
)
void
DataTypeDecimal
<
T
>::
readText
(
T
&
x
,
ReadBuffer
&
istr
,
UInt32
precision
,
UInt32
scale
,
bool
csv
)
{
UInt32
unread_scale
=
scale
;
readDecimalText
(
istr
,
x
,
precision
,
unread_scale
);
if
(
csv
)
readCSVDecimalText
(
istr
,
x
,
precision
,
unread_scale
);
else
readDecimalText
(
istr
,
x
,
precision
,
unread_scale
);
x
*=
getScaleMultiplier
(
unread_scale
);
}
...
...
@@ -67,6 +70,13 @@ void DataTypeDecimal<T>::deserializeText(IColumn & column, ReadBuffer & istr, co
static_cast
<
ColumnType
&>
(
column
).
getData
().
push_back
(
x
);
}
template
<
typename
T
>
void
DataTypeDecimal
<
T
>::
deserializeTextCSV
(
IColumn
&
column
,
ReadBuffer
&
istr
,
const
FormatSettings
&
)
const
{
T
x
;
readText
(
x
,
istr
,
true
);
static_cast
<
ColumnType
&>
(
column
).
getData
().
push_back
(
x
);
}
template
<
typename
T
>
T
DataTypeDecimal
<
T
>::
parseFromString
(
const
String
&
str
)
const
...
...
dbms/src/DataTypes/DataTypesDecimal.h
浏览文件 @
720f8667
...
...
@@ -91,6 +91,7 @@ public:
void
serializeText
(
const
IColumn
&
column
,
size_t
row_num
,
WriteBuffer
&
ostr
,
const
FormatSettings
&
)
const
override
;
void
deserializeText
(
IColumn
&
column
,
ReadBuffer
&
istr
,
const
FormatSettings
&
)
const
override
;
void
deserializeTextCSV
(
IColumn
&
column
,
ReadBuffer
&
istr
,
const
FormatSettings
&
)
const
override
;
void
serializeBinary
(
const
Field
&
field
,
WriteBuffer
&
ostr
)
const
override
;
void
serializeBinary
(
const
IColumn
&
column
,
size_t
row_num
,
WriteBuffer
&
ostr
)
const
override
;
...
...
@@ -175,8 +176,8 @@ public:
T
parseFromString
(
const
String
&
str
)
const
;
void
readText
(
T
&
x
,
ReadBuffer
&
istr
)
const
{
readText
(
x
,
istr
,
precision
,
scale
);
}
static
void
readText
(
T
&
x
,
ReadBuffer
&
istr
,
UInt32
precision
,
UInt32
scale
);
void
readText
(
T
&
x
,
ReadBuffer
&
istr
,
bool
csv
=
false
)
const
{
readText
(
x
,
istr
,
precision
,
scale
,
csv
);
}
static
void
readText
(
T
&
x
,
ReadBuffer
&
istr
,
UInt32
precision
,
UInt32
scale
,
bool
csv
=
false
);
static
T
getScaleMultiplier
(
UInt32
scale
);
private:
...
...
dbms/src/IO/readFloatText.h
浏览文件 @
720f8667
...
...
@@ -668,6 +668,22 @@ inline void readDecimalText(ReadBuffer & buf, T & x, unsigned int precision, uns
scale
+=
exponent
;
}
template
<
typename
T
>
inline
void
readCSVDecimalText
(
ReadBuffer
&
buf
,
T
&
x
,
unsigned
int
precision
,
unsigned
int
&
scale
)
{
if
(
buf
.
eof
())
throwReadAfterEOF
();
char
maybe_quote
=
*
buf
.
position
();
if
(
maybe_quote
==
'\''
||
maybe_quote
==
'\"'
)
++
buf
.
position
();
readDecimalText
(
buf
,
x
,
precision
,
scale
,
false
);
if
(
maybe_quote
==
'\''
||
maybe_quote
==
'\"'
)
assertChar
(
maybe_quote
,
buf
);
}
template
<
typename
T
>
void
readFloatTextPrecise
(
T
&
x
,
ReadBuffer
&
in
)
{
readFloatTextPreciseImpl
<
T
,
void
>
(
x
,
in
);
}
template
<
typename
T
>
bool
tryReadFloatTextPrecise
(
T
&
x
,
ReadBuffer
&
in
)
{
return
readFloatTextPreciseImpl
<
T
,
bool
>
(
x
,
in
);
}
...
...
dbms/tests/queries/0_stateless/00861_decimal_quoted_csv.reference
0 → 100644
浏览文件 @
720f8667
1 1.00 1.00 1.00
2 -1.00 -1.00 -1.00
3 1.00 1.00 1.00
4 -0.10 -0.10 -0.10
5 0.01 0.01 0.01
dbms/tests/queries/0_stateless/00861_decimal_quoted_csv.sql
0 → 100644
浏览文件 @
720f8667
DROP
TABLE
IF
EXISTS
test
;
CREATE
TABLE
test
(
key
UInt64
,
d32
Decimal32
(
2
),
d64
Decimal64
(
2
),
d128
Decimal128
(
2
))
ENGINE
=
Memory
;
INSERT
INTO
test
FORMAT
CSV
"1"
,
"1"
,
"1"
,
"1"
;
INSERT
INTO
test
FORMAT
CSV
"2"
,
"-1"
,
"-1"
,
"-1"
;
INSERT
INTO
test
FORMAT
CSV
"3"
,
"1.0"
,
"1.0"
,
"1.0"
;
INSERT
INTO
test
FORMAT
CSV
"4"
,
"-0.1"
,
"-0.1"
,
"-0.1"
;
INSERT
INTO
test
FORMAT
CSV
"5"
,
"0.010"
,
"0.010"
,
"0.010"
;
SELECT
*
FROM
test
ORDER
BY
key
;
DROP
TABLE
test
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录