Fixed convert function monotonic failure when string data type

This commit is contained in:
zhang2014 2018-12-19 14:57:37 +08:00
parent 6869771ae4
commit dc61a73a6e
3 changed files with 15 additions and 5 deletions

View File

@ -1138,6 +1138,10 @@ struct ToIntMonotonicity
static IFunction::Monotonicity get(const IDataType & type, const Field & left, const Field & right)
{
/// If type is string, the function is no monotonic
if (WhichDataType(type).isString())
return {};
size_t size_of_type = type.getSizeOfValueInMemory();
/// If type is expanding

View File

@ -1,5 +1,10 @@
drop table if exists test.table;
create table test.table (val Int32) engine = MergeTree order by val;
insert into test.table values (-2), (0), (2);
select count() from test.table where toUInt64(val) == 0;
DROP TABLE IF EXISTS test.number_test_table;
DROP TABLE IF EXISTS test.string_test_table;
CREATE TABLE test.number_test_table (val Int32) ENGINE = MergeTree ORDER BY val;
CREATE TABLE test.string_test_table (val String) ENGINE = MergeTree ORDER BY val;
INSERT INTO test.number_test_table VALUES (-2), (0), (2);
INSERT INTO test.string_test_table VALUES ('0'), ('2');
SELECT count() FROM test.number_test_table WHERE toUInt64(val) == 0;
SELECT count() FROM test.string_test_table WHERE toUInt64(val) == 0;
DROP TABLE IF EXISTS test.number_test_table;
DROP TABLE IF EXISTS test.string_test_table;