Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
fd6115cc
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,发现更多精彩内容 >>
未验证
提交
fd6115cc
编写于
6月 15, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
6月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11648 from ClickHouse/simplify-code-functions-comparison-3
Allow comparison with String in index analysis; simplify code.
上级
550838ad
6467302a
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
199 addition
and
250 deletion
+199
-250
src/Common/Arena.h
src/Common/Arena.h
+2
-2
src/Common/ArenaWithFreeLists.h
src/Common/ArenaWithFreeLists.h
+2
-2
src/Common/FieldVisitors.h
src/Common/FieldVisitors.h
+0
-239
src/Common/FieldVisitorsAccurateComparison.h
src/Common/FieldVisitorsAccurateComparison.h
+142
-0
src/Core/Defines.h
src/Core/Defines.h
+1
-1
src/Functions/array/arrayIndex.h
src/Functions/array/arrayIndex.h
+1
-1
src/Interpreters/FillingRow.cpp
src/Interpreters/FillingRow.cpp
+2
-0
src/Interpreters/FillingRow.h
src/Interpreters/FillingRow.h
+1
-1
src/Interpreters/InterpreterSelectQuery.cpp
src/Interpreters/InterpreterSelectQuery.cpp
+1
-1
src/Storages/MergeTree/KeyCondition.cpp
src/Storages/MergeTree/KeyCondition.cpp
+3
-3
tests/queries/0_stateless/01312_comparison_with_constant_string_in_index_analysis.reference
...mparison_with_constant_string_in_index_analysis.reference
+12
-0
tests/queries/0_stateless/01312_comparison_with_constant_string_in_index_analysis.sql
...312_comparison_with_constant_string_in_index_analysis.sql
+32
-0
未找到文件。
src/Common/Arena.h
浏览文件 @
fd6115cc
...
...
@@ -4,10 +4,10 @@
#include <memory>
#include <vector>
#include <boost/noncopyable.hpp>
#if __has_include(<sanitizer/asan_interface.h>)
#include <Core/Defines.h>
#if __has_include(<sanitizer/asan_interface.h>) && defined(ADDRESS_SANITIZER)
# include <sanitizer/asan_interface.h>
#endif
#include <Core/Defines.h>
#include <Common/memcpySmall.h>
#include <Common/ProfileEvents.h>
#include <Common/Allocator.h>
...
...
src/Common/ArenaWithFreeLists.h
浏览文件 @
fd6115cc
#pragma once
#if __has_include(<sanitizer/asan_interface.h>)
#include <Core/Defines.h>
#if __has_include(<sanitizer/asan_interface.h>) && defined(ADDRESS_SANITIZER)
# include <sanitizer/asan_interface.h>
#endif
#include <Core/Defines.h>
#include <Common/Arena.h>
#include <Common/BitHelpers.h>
...
...
src/Common/FieldVisitors.h
浏览文件 @
fd6115cc
#pragma once
#include <Core/Field.h>
#include <Core/AccurateComparison.h>
#include <common/demangle.h>
...
...
@@ -14,7 +13,6 @@ namespace DB
namespace
ErrorCodes
{
extern
const
int
CANNOT_CONVERT_TYPE
;
extern
const
int
BAD_TYPE_OF_FIELD
;
extern
const
int
LOGICAL_ERROR
;
}
...
...
@@ -177,243 +175,6 @@ template <> constexpr bool isDecimalField<DecimalField<Decimal64>>() { return tr
template
<
>
constexpr
bool
isDecimalField
<
DecimalField
<
Decimal128
>>
()
{
return
true
;
}
/** More precise comparison, used for index.
* Differs from Field::operator< and Field::operator== in that it also compares values of different types.
* Comparison rules are same as in FunctionsComparison (to be consistent with expression evaluation in query).
*/
class
FieldVisitorAccurateEquals
:
public
StaticVisitor
<
bool
>
{
public:
bool
operator
()
(
const
UInt64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
UInt64
&
l
,
const
UInt64
&
r
)
const
{
return
l
==
r
;
}
bool
operator
()
(
const
UInt64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Int64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Float64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
Int64
&
l
,
const
UInt64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Int64
&
r
)
const
{
return
l
==
r
;
}
bool
operator
()
(
const
Int64
&
l
,
const
Float64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
Float64
&
l
,
const
UInt64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Int64
&
r
)
const
{
return
accurate
::
equalsOp
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Float64
&
r
)
const
{
return
l
==
r
;
}
bool
operator
()
(
const
Float64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Null
&
,
const
T
&
)
const
{
return
std
::
is_same_v
<
T
,
Null
>
;
}
template
<
typename
T
>
bool
operator
()
(
const
String
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
return
l
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
stringToUUID
(
l
)
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
UInt128
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
l
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
return
l
==
stringToUUID
(
r
);
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Array
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Array
>
)
return
l
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Tuple
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Tuple
>
)
return
l
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
,
typename
U
>
bool
operator
()
(
const
DecimalField
<
T
>
&
l
,
const
U
&
r
)
const
{
if
constexpr
(
isDecimalField
<
U
>
())
return
l
==
r
;
if
constexpr
(
std
::
is_same_v
<
U
,
Int64
>
||
std
::
is_same_v
<
U
,
UInt64
>
)
return
l
==
DecimalField
<
Decimal128
>
(
r
,
0
);
if
constexpr
(
std
::
is_same_v
<
U
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
UInt64
&
l
,
const
DecimalField
<
T
>
&
r
)
const
{
return
DecimalField
<
Decimal128
>
(
l
,
0
)
==
r
;
}
template
<
typename
T
>
bool
operator
()
(
const
Int64
&
l
,
const
DecimalField
<
T
>
&
r
)
const
{
return
DecimalField
<
Decimal128
>
(
l
,
0
)
==
r
;
}
template
<
typename
T
>
bool
operator
()
(
const
Float64
&
l
,
const
DecimalField
<
T
>
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
AggregateFunctionStateData
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
AggregateFunctionStateData
>
)
return
l
==
r
;
return
cantCompare
(
l
,
r
);
}
private:
template
<
typename
T
,
typename
U
>
bool
cantCompare
(
const
T
&
,
const
U
&
)
const
{
if
constexpr
(
std
::
is_same_v
<
U
,
Null
>
)
return
false
;
throw
Exception
(
"Cannot compare "
+
demangle
(
typeid
(
T
).
name
())
+
" with "
+
demangle
(
typeid
(
U
).
name
()),
ErrorCodes
::
BAD_TYPE_OF_FIELD
);
}
};
class
FieldVisitorAccurateLess
:
public
StaticVisitor
<
bool
>
{
public:
bool
operator
()
(
const
UInt64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
UInt64
&
l
,
const
UInt64
&
r
)
const
{
return
l
<
r
;
}
bool
operator
()
(
const
UInt64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Int64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Float64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
UInt64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
Int64
&
l
,
const
UInt64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Int64
&
r
)
const
{
return
l
<
r
;
}
bool
operator
()
(
const
Int64
&
l
,
const
Float64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Int64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
,
const
Null
&
)
const
{
return
false
;
}
bool
operator
()
(
const
Float64
&
l
,
const
UInt64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
UInt128
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Int64
&
r
)
const
{
return
accurate
::
lessOp
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Float64
&
r
)
const
{
return
l
<
r
;
}
bool
operator
()
(
const
Float64
&
l
,
const
String
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Array
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
Tuple
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
bool
operator
()
(
const
Float64
&
l
,
const
AggregateFunctionStateData
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Null
&
,
const
T
&
)
const
{
return
!
std
::
is_same_v
<
T
,
Null
>
;
}
template
<
typename
T
>
bool
operator
()
(
const
String
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
return
l
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
stringToUUID
(
l
)
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
UInt128
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
l
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
return
l
<
stringToUUID
(
r
);
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Array
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Array
>
)
return
l
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
Tuple
&
l
,
const
T
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Tuple
>
)
return
l
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
,
typename
U
>
bool
operator
()
(
const
DecimalField
<
T
>
&
l
,
const
U
&
r
)
const
{
if
constexpr
(
isDecimalField
<
U
>
())
return
l
<
r
;
if
constexpr
(
std
::
is_same_v
<
U
,
Int64
>
||
std
::
is_same_v
<
U
,
UInt64
>
)
return
l
<
DecimalField
<
Decimal128
>
(
r
,
0
);
if
constexpr
(
std
::
is_same_v
<
U
,
Null
>
)
return
false
;
return
cantCompare
(
l
,
r
);
}
template
<
typename
T
>
bool
operator
()
(
const
UInt64
&
l
,
const
DecimalField
<
T
>
&
r
)
const
{
return
DecimalField
<
Decimal128
>
(
l
,
0
)
<
r
;
}
template
<
typename
T
>
bool
operator
()
(
const
Int64
&
l
,
const
DecimalField
<
T
>
&
r
)
const
{
return
DecimalField
<
Decimal128
>
(
l
,
0
)
<
r
;
}
template
<
typename
T
>
bool
operator
()
(
const
Float64
&
,
const
DecimalField
<
T
>
&
)
const
{
return
false
;
}
template
<
typename
T
>
bool
operator
()
(
const
AggregateFunctionStateData
&
l
,
const
T
&
r
)
const
{
return
cantCompare
(
l
,
r
);
}
private:
template
<
typename
T
,
typename
U
>
bool
cantCompare
(
const
T
&
,
const
U
&
)
const
{
throw
Exception
(
"Cannot compare "
+
demangle
(
typeid
(
T
).
name
())
+
" with "
+
demangle
(
typeid
(
U
).
name
()),
ErrorCodes
::
BAD_TYPE_OF_FIELD
);
}
};
/** Implements `+=` operation.
* Returns false if the result is zero.
*/
...
...
src/Common/FieldVisitorsAccurateComparison.h
0 → 100644
浏览文件 @
fd6115cc
#pragma once
#include <Core/Field.h>
#include <Core/AccurateComparison.h>
#include <common/demangle.h>
#include <Common/FieldVisitors.h>
#include <IO/ReadBufferFromString.h>
#include <IO/ReadHelpers.h>
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
BAD_TYPE_OF_FIELD
;
}
/** More precise comparison, used for index.
* Differs from Field::operator< and Field::operator== in that it also compares values of different types.
* Comparison rules are same as in FunctionsComparison (to be consistent with expression evaluation in query).
*/
class
FieldVisitorAccurateEquals
:
public
StaticVisitor
<
bool
>
{
public:
template
<
typename
T
,
typename
U
>
bool
operator
()
(
const
T
&
l
,
const
U
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
||
std
::
is_same_v
<
U
,
Null
>
)
return
std
::
is_same_v
<
T
,
U
>
;
else
{
if
constexpr
(
std
::
is_same_v
<
T
,
U
>
)
return
l
==
r
;
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
&&
std
::
is_arithmetic_v
<
U
>
)
return
accurate
::
equalsOp
(
l
,
r
);
if
constexpr
(
isDecimalField
<
T
>
()
&&
isDecimalField
<
U
>
())
return
l
==
r
;
if
constexpr
(
isDecimalField
<
T
>
()
&&
std
::
is_arithmetic_v
<
U
>
)
return
l
==
DecimalField
<
Decimal128
>
(
r
,
0
);
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
&&
isDecimalField
<
U
>
())
return
DecimalField
<
Decimal128
>
(
l
,
0
)
==
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
{
if
constexpr
(
std
::
is_same_v
<
U
,
UInt128
>
)
return
stringToUUID
(
l
)
==
r
;
if
constexpr
(
std
::
is_arithmetic_v
<
U
>
)
{
ReadBufferFromString
in
(
l
);
T
parsed
;
readText
(
parsed
,
in
);
return
operator
()(
parsed
,
r
);
}
}
if
constexpr
(
std
::
is_same_v
<
U
,
String
>
)
{
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
l
==
stringToUUID
(
r
);
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
ReadBufferFromString
in
(
r
);
T
parsed
;
readText
(
parsed
,
in
);
return
operator
()(
l
,
parsed
);
}
}
}
throw
Exception
(
"Cannot compare "
+
demangle
(
typeid
(
T
).
name
())
+
" with "
+
demangle
(
typeid
(
U
).
name
()),
ErrorCodes
::
BAD_TYPE_OF_FIELD
);
}
};
class
FieldVisitorAccurateLess
:
public
StaticVisitor
<
bool
>
{
public:
template
<
typename
T
,
typename
U
>
bool
operator
()
(
const
T
&
l
,
const
U
&
r
)
const
{
if
constexpr
(
std
::
is_same_v
<
T
,
Null
>
||
std
::
is_same_v
<
U
,
Null
>
)
return
false
;
else
{
if
constexpr
(
std
::
is_same_v
<
T
,
U
>
)
return
l
<
r
;
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
&&
std
::
is_arithmetic_v
<
U
>
)
return
accurate
::
lessOp
(
l
,
r
);
if
constexpr
(
isDecimalField
<
T
>
()
&&
isDecimalField
<
U
>
())
return
l
<
r
;
if
constexpr
(
isDecimalField
<
T
>
()
&&
std
::
is_arithmetic_v
<
U
>
)
return
l
<
DecimalField
<
Decimal128
>
(
r
,
0
);
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
&&
isDecimalField
<
U
>
())
return
DecimalField
<
Decimal128
>
(
l
,
0
)
<
r
;
if
constexpr
(
std
::
is_same_v
<
T
,
String
>
)
{
if
constexpr
(
std
::
is_same_v
<
U
,
UInt128
>
)
return
stringToUUID
(
l
)
<
r
;
if
constexpr
(
std
::
is_arithmetic_v
<
U
>
)
{
ReadBufferFromString
in
(
l
);
T
parsed
;
readText
(
parsed
,
in
);
return
operator
()(
parsed
,
r
);
}
}
if
constexpr
(
std
::
is_same_v
<
U
,
String
>
)
{
if
constexpr
(
std
::
is_same_v
<
T
,
UInt128
>
)
return
l
<
stringToUUID
(
r
);
if
constexpr
(
std
::
is_arithmetic_v
<
T
>
)
{
ReadBufferFromString
in
(
r
);
T
parsed
;
readText
(
parsed
,
in
);
return
operator
()(
l
,
parsed
);
}
}
}
throw
Exception
(
"Cannot compare "
+
demangle
(
typeid
(
T
).
name
())
+
" with "
+
demangle
(
typeid
(
U
).
name
()),
ErrorCodes
::
BAD_TYPE_OF_FIELD
);
}
};
}
src/Core/Defines.h
浏览文件 @
fd6115cc
...
...
@@ -87,7 +87,7 @@
#define DBMS_DISTRIBUTED_SIGNATURE_HEADER 0xCAFEDACEull
#define DBMS_DISTRIBUTED_SIGNATURE_HEADER_OLD_FORMAT 0xCAFECABEull
#if !__has_include(<sanitizer/asan_interface.h>)
#if !__has_include(<sanitizer/asan_interface.h>)
|| !defined(ADDRESS_SANITIZER)
# define ASAN_UNPOISON_MEMORY_REGION(a, b)
# define ASAN_POISON_MEMORY_REGION(a, b)
#endif
...
...
src/Functions/array/arrayIndex.h
浏览文件 @
fd6115cc
...
...
@@ -9,7 +9,7 @@
#include <Columns/ColumnFixedString.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnNullable.h>
#include <Common/FieldVisitors.h>
#include <Common/FieldVisitors
AccurateComparison
.h>
#include <Common/memcmpSmall.h>
#include <Common/assert_cast.h>
...
...
src/Interpreters/FillingRow.cpp
浏览文件 @
fd6115cc
#include <Interpreters/FillingRow.h>
#include <Common/FieldVisitorsAccurateComparison.h>
namespace
DB
{
...
...
src/Interpreters/FillingRow.h
浏览文件 @
fd6115cc
#pragma once
#include <Core/SortDescription.h>
#include <Columns/IColumn.h>
#include <Common/FieldVisitors.h>
namespace
DB
{
...
...
src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
fd6115cc
...
...
@@ -37,7 +37,7 @@
#include <Core/Field.h>
#include <Core/Types.h>
#include <Columns/Collator.h>
#include <Common/FieldVisitors.h>
#include <Common/FieldVisitors
AccurateComparison
.h>
#include <Common/typeid_cast.h>
#include <Common/checkStackSize.h>
#include <ext/map.h>
...
...
src/Storages/MergeTree/KeyCondition.cpp
浏览文件 @
fd6115cc
...
...
@@ -7,7 +7,7 @@
#include <Interpreters/misc.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/FieldVisitors.h>
#include <Common/FieldVisitors
AccurateComparison
.h>
#include <Common/typeid_cast.h>
#include <Interpreters/convertFieldToType.h>
#include <Interpreters/Set.h>
...
...
@@ -826,8 +826,8 @@ bool KeyCondition::tryParseAtomFromAST(const ASTPtr & node, const Context & cont
}
bool
cast_not_needed
=
is_set_const
/// Set args are already casted inside Set::createFromAST
||
(
isNativeNumber
(
key_expr_type
)
&&
isNativeNumber
(
const_type
));
/// Numbers are accurately compared without cast.
is_set_const
/// Set args are already casted inside Set::createFromAST
||
(
isNativeNumber
(
key_expr_type
)
&&
isNativeNumber
(
const_type
));
/// Numbers are accurately compared without cast.
if
(
!
cast_not_needed
)
castValueToType
(
key_expr_type
,
const_value
,
const_type
,
node
);
...
...
tests/queries/0_stateless/01312_comparison_with_constant_string_in_index_analysis.reference
0 → 100644
浏览文件 @
fd6115cc
1
999999
100000
899999
100001
900000
1
999999
100000
899999
100001
900000
tests/queries/0_stateless/01312_comparison_with_constant_string_in_index_analysis.sql
0 → 100644
浏览文件 @
fd6115cc
DROP
TABLE
IF
EXISTS
test
;
CREATE
TABLE
test
(
x
UInt64
)
ENGINE
=
MergeTree
ORDER
BY
x
SETTINGS
index_granularity
=
1000
;
INSERT
INTO
test
SELECT
*
FROM
numbers
(
1000000
);
OPTIMIZE
TABLE
test
;
SET
max_rows_to_read
=
2000
;
SELECT
count
()
FROM
test
WHERE
x
=
100000
;
SET
max_rows_to_read
=
1000000
;
SELECT
count
()
FROM
test
WHERE
x
!=
100000
;
SET
max_rows_to_read
=
101000
;
SELECT
count
()
FROM
test
WHERE
x
<
100000
;
SET
max_rows_to_read
=
900000
;
SELECT
count
()
FROM
test
WHERE
x
>
100000
;
SET
max_rows_to_read
=
101000
;
SELECT
count
()
FROM
test
WHERE
x
<=
100000
;
SET
max_rows_to_read
=
901000
;
SELECT
count
()
FROM
test
WHERE
x
>=
100000
;
SET
max_rows_to_read
=
2000
;
SELECT
count
()
FROM
test
WHERE
x
=
'100000'
;
SET
max_rows_to_read
=
1000000
;
SELECT
count
()
FROM
test
WHERE
x
!=
'100000'
;
SET
max_rows_to_read
=
101000
;
SELECT
count
()
FROM
test
WHERE
x
<
'100000'
;
SET
max_rows_to_read
=
900000
;
SELECT
count
()
FROM
test
WHERE
x
>
'100000'
;
SET
max_rows_to_read
=
101000
;
SELECT
count
()
FROM
test
WHERE
x
<=
'100000'
;
SET
max_rows_to_read
=
901000
;
SELECT
count
()
FROM
test
WHERE
x
>=
'100000'
;
DROP
TABLE
test
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录