Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
57104f81
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,发现更多精彩内容 >>
提交
57104f81
编写于
1月 25, 2019
作者:
L
Léo Ercolanelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename `widen` to `promote` for IDataType
上级
0d6094a3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
22 addition
and
22 deletion
+22
-22
dbms/src/AggregateFunctions/AggregateFunctionSumMap.h
dbms/src/AggregateFunctions/AggregateFunctionSumMap.h
+4
-4
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-1
dbms/src/DataTypes/DataTypesDecimal.cpp
dbms/src/DataTypes/DataTypesDecimal.cpp
+3
-3
dbms/src/DataTypes/DataTypesDecimal.h
dbms/src/DataTypes/DataTypesDecimal.h
+2
-2
dbms/src/DataTypes/DataTypesNumber.h
dbms/src/DataTypes/DataTypesNumber.h
+4
-4
dbms/src/DataTypes/IDataType.cpp
dbms/src/DataTypes/IDataType.cpp
+3
-3
dbms/src/DataTypes/IDataType.h
dbms/src/DataTypes/IDataType.h
+5
-5
未找到文件。
dbms/src/AggregateFunctions/AggregateFunctionSumMap.h
浏览文件 @
57104f81
...
...
@@ -72,7 +72,7 @@ public:
types
.
emplace_back
(
std
::
make_shared
<
DataTypeArray
>
(
keys_type
));
for
(
const
auto
&
value_type
:
values_types
)
types
.
emplace_back
(
std
::
make_shared
<
DataTypeArray
>
(
widenData
Type
(
value_type
)));
types
.
emplace_back
(
std
::
make_shared
<
DataTypeArray
>
(
promoteNumeric
Type
(
value_type
)));
return
std
::
make_shared
<
DataTypeTuple
>
(
types
);
}
...
...
@@ -262,13 +262,13 @@ public:
bool
keepKey
(
const
T
&
key
)
const
{
return
static_cast
<
const
Derived
&>
(
*
this
).
keepKey
(
key
);
}
private:
static
DataTypePtr
widenData
Type
(
const
DataTypePtr
&
data_type
)
static
DataTypePtr
promoteNumeric
Type
(
const
DataTypePtr
&
data_type
)
{
if
(
!
data_type
->
canBe
Widen
())
if
(
!
data_type
->
canBe
Promoted
())
throw
new
Exception
{
"Values to be summed are expected to be Numeric, Float or Decimal."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
return
data_type
->
getWidenData
Type
();
return
data_type
->
promoteNumeric
Type
();
}
};
...
...
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
57104f81
...
...
@@ -412,7 +412,7 @@ namespace ErrorCodes
extern
const
int
NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD
=
435
;
extern
const
int
CANNOT_CONVERT_TO_PROTOBUF_TYPE
=
436
;
extern
const
int
PROTOBUF_FIELD_NOT_REPEATED
=
437
;
extern
const
int
DATA_TYPE_CANNOT_BE_
WIDEN
=
438
;
extern
const
int
DATA_TYPE_CANNOT_BE_
PROMOTED
=
438
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/DataTypes/DataTypesDecimal.cpp
浏览文件 @
57104f81
...
...
@@ -149,10 +149,10 @@ Field DataTypeDecimal<T>::getDefault() const
template
<
typename
T
>
DataTypePtr
DataTypeDecimal
<
T
>::
getWidenData
Type
()
const
DataTypePtr
DataTypeDecimal
<
T
>::
promoteNumeric
Type
()
const
{
using
WidenData
Type
=
DataTypeDecimal
<
Decimal128
>
;
return
std
::
make_shared
<
WidenDataType
>
(
WidenData
Type
::
maxPrecision
(),
scale
);
using
Promoted
Type
=
DataTypeDecimal
<
Decimal128
>
;
return
std
::
make_shared
<
PromotedType
>
(
Promoted
Type
::
maxPrecision
(),
scale
);
}
...
...
dbms/src/DataTypes/DataTypesDecimal.h
浏览文件 @
57104f81
...
...
@@ -103,8 +103,8 @@ public:
void
serializeProtobuf
(
const
IColumn
&
column
,
size_t
row_num
,
ProtobufWriter
&
protobuf
)
const
override
;
Field
getDefault
()
const
override
;
bool
canBe
Widen
()
const
override
{
return
true
;
}
DataTypePtr
getWidenData
Type
()
const
override
;
bool
canBe
Promoted
()
const
override
{
return
true
;
}
DataTypePtr
promoteNumeric
Type
()
const
override
;
MutableColumnPtr
createColumn
()
const
override
;
bool
equals
(
const
IDataType
&
rhs
)
const
override
;
...
...
dbms/src/DataTypes/DataTypesNumber.h
浏览文件 @
57104f81
...
...
@@ -18,11 +18,11 @@ class DataTypeNumber final : public DataTypeNumberBase<T>
bool
canBeUsedInBooleanContext
()
const
override
{
return
true
;
}
bool
canBeInsideNullable
()
const
override
{
return
true
;
}
bool
canBe
Widen
()
const
override
{
return
true
;
}
DataTypePtr
getWidenData
Type
()
const
override
bool
canBe
Promoted
()
const
override
{
return
true
;
}
DataTypePtr
promoteNumeric
Type
()
const
override
{
using
WidenData
Type
=
DataTypeNumber
<
NearestFieldType
<
T
>>
;
return
std
::
make_shared
<
WidenData
Type
>
();
using
Promoted
Type
=
DataTypeNumber
<
NearestFieldType
<
T
>>
;
return
std
::
make_shared
<
Promoted
Type
>
();
}
};
...
...
dbms/src/DataTypes/IDataType.cpp
浏览文件 @
57104f81
...
...
@@ -19,7 +19,7 @@ namespace ErrorCodes
{
extern
const
int
MULTIPLE_STREAMS_REQUIRED
;
extern
const
int
LOGICAL_ERROR
;
extern
const
int
DATA_TYPE_CANNOT_BE_
WIDEN
;
extern
const
int
DATA_TYPE_CANNOT_BE_
PROMOTED
;
}
...
...
@@ -52,9 +52,9 @@ ColumnPtr IDataType::createColumnConstWithDefaultValue(size_t size) const
return
createColumnConst
(
size
,
getDefault
());
}
DataTypePtr
IDataType
::
getWidenData
Type
()
const
DataTypePtr
IDataType
::
promoteNumeric
Type
()
const
{
throw
Exception
(
"Data type "
+
getName
()
+
" can't be
widen."
,
ErrorCodes
::
DATA_TYPE_CANNOT_BE_WIDEN
);
throw
Exception
(
"Data type "
+
getName
()
+
" can't be
promoted."
,
ErrorCodes
::
DATA_TYPE_CANNOT_BE_PROMOTED
);
}
void
IDataType
::
serializeBinaryBulk
(
const
IColumn
&
,
WriteBuffer
&
,
size_t
,
size_t
)
const
...
...
dbms/src/DataTypes/IDataType.h
浏览文件 @
57104f81
...
...
@@ -273,14 +273,14 @@ public:
*/
virtual
Field
getDefault
()
const
=
0
;
/** The data type can be
widen
in order to try to avoid overflows.
*
Widenable data types
are typically Number or Decimal data types.
/** The data type can be
promoted
in order to try to avoid overflows.
*
Data types which can be promoted
are typically Number or Decimal data types.
*/
virtual
bool
canBe
Widen
()
const
{
return
false
;
}
virtual
bool
canBe
Promoted
()
const
{
return
false
;
}
/** Return the
widen data type of the current data type. Throw an exception if `canBeWiden
() == false`.
/** Return the
promoted numeric data type of the current data type. Throw an exception if `canBePromoted
() == false`.
*/
virtual
DataTypePtr
getWidenData
Type
()
const
;
virtual
DataTypePtr
promoteNumeric
Type
()
const
;
/** Directly insert default value into a column. Default implementation use method IColumn::insertDefault.
* This should be overriden if data type default value differs from column default value (example: Enum data types).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录