mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Revert "Fix index analysis for DateTime64
"
This commit is contained in:
parent
95af8eb88d
commit
1e03649826
@ -4853,7 +4853,7 @@ FunctionBasePtr createFunctionBaseCast(
|
|||||||
DataTypeUInt8, DataTypeUInt16, DataTypeUInt32, DataTypeUInt64, DataTypeUInt128, DataTypeUInt256,
|
DataTypeUInt8, DataTypeUInt16, DataTypeUInt32, DataTypeUInt64, DataTypeUInt128, DataTypeUInt256,
|
||||||
DataTypeInt8, DataTypeInt16, DataTypeInt32, DataTypeInt64, DataTypeInt128, DataTypeInt256,
|
DataTypeInt8, DataTypeInt16, DataTypeInt32, DataTypeInt64, DataTypeInt128, DataTypeInt256,
|
||||||
DataTypeFloat32, DataTypeFloat64,
|
DataTypeFloat32, DataTypeFloat64,
|
||||||
DataTypeDate, DataTypeDate32, DataTypeDateTime, DataTypeDateTime64,
|
DataTypeDate, DataTypeDate32, DataTypeDateTime,
|
||||||
DataTypeString>(return_type.get(), [&](auto & type)
|
DataTypeString>(return_type.get(), [&](auto & type)
|
||||||
{
|
{
|
||||||
monotonicity = FunctionTo<std::decay_t<decltype(type)>>::Type::Monotonic::get;
|
monotonicity = FunctionTo<std::decay_t<decltype(type)>>::Type::Monotonic::get;
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
drop table if exists dt64_monot_test;
|
||||||
|
drop table if exists dt64_monot_test_string;
|
||||||
|
CREATE TABLE dt64_monot_test(`date_time` DateTime64(3, 'Europe/Berlin'), `id` String) ENGINE = MergeTree PARTITION BY toDate(date_time, 'Europe/Berlin') ORDER BY date_time;
|
||||||
|
insert into dt64_monot_test select toDateTime64('2020-01-01 00:00:00.000',3)+number , '' from numbers(10);
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime(date_time) >= toDateTime('2020-01-01 00:00:00') SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time, 3) >= '2020-01-01 00:00:01.111' SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time, 3) >= '2020-01-01 00:00:00.000' SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) >= toDateTime64('2020-01-01 00:00:00.000001', 3) SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) >= toDateTime64('2020-01-01 00:00:00.000001', 3, 'Europe/Berlin') SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) >= toDateTime64('2020-01-01 00:00:00.000001',6) SETTINGS force_index_by_date = 1; -- { serverError 277}
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) >= toDateTime64('2020-01-01 00:00:00.000001',6, 'Europe/Berlin') SETTINGS force_primary_key = 1; -- { serverError 277}
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) >= toDateTime64('2020-01-01 00:00:00.000001',6) SETTINGS force_primary_key = 1; -- { serverError 277}
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) <= toDateTime64('2020-01-01 00:00:00.000001',3, 'Europe/Berlin') settings force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) <= toDateTime64('2020-01-01 00:00:00.000001',3) settings force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) = toDateTime64('2020-01-01 00:00:00.000000',6);
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,3) = toDateTime64('2020-01-01 00:00:00.000000',6, 'Europe/Berlin');
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,6) = toDateTime64('2020-01-01 00:00:00.000000',6) settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,6) = toDateTime64('2020-01-01 00:00:00.000001',6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,6) > toDateTime64('2020-01-01 00:00:00.000001',6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,6) >= toDateTime64('2020-01-01 00:00:00.000001',6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,6) >= toDateTime64('2020-01-01 00:00:00.000001',6) settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,0) >= toDateTime64('2020-01-01 00:00:00.000001',0, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,0) >= toDateTime64('2020-01-01 00:00:00.000001',0) settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,0) >= '2020-01-01 00:00:00' settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test WHERE toDateTime64(date_time,0) >= '2020-01-01 00:00:01.1' settings force_index_by_date = 1, force_primary_key = 1;
|
||||||
|
|
||||||
|
create table dt64_monot_test_string(date_time String, x String) Engine=MergeTree order by date_time;
|
||||||
|
insert into dt64_monot_test_string select '2020-01-01 00:00:00.000000001', '' from numbers(1);
|
||||||
|
insert into dt64_monot_test_string select '2020-01-01 00:00:00.000', '' from numbers(10);
|
||||||
|
|
||||||
|
SELECT count() FROM dt64_monot_test_string WHERE toDateTime64(date_time,9) = '2020-01-01 00:00:00.000000000';
|
||||||
|
SELECT count() FROM dt64_monot_test_string WHERE toDateTime64(date_time,3) = '2020-01-01 00:00:00.000000001';
|
||||||
|
SELECT count() FROM dt64_monot_test_string WHERE toDateTime64(date_time,9) = '2020-01-01 00:00:00';
|
||||||
|
|
||||||
|
drop table dt64_monot_test;
|
||||||
|
drop table dt64_monot_test_string;
|
@ -4,9 +4,6 @@ Asia/Tehran
|
|||||||
0
|
0
|
||||||
10
|
10
|
||||||
0
|
0
|
||||||
9
|
|
||||||
0
|
|
||||||
9
|
|
||||||
10
|
10
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -30,9 +27,6 @@ UTC
|
|||||||
10
|
10
|
||||||
10
|
10
|
||||||
10
|
10
|
||||||
9
|
|
||||||
10
|
|
||||||
9
|
|
||||||
0
|
0
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -56,9 +50,6 @@ Canada/Atlantic
|
|||||||
10
|
10
|
||||||
10
|
10
|
||||||
10
|
10
|
||||||
9
|
|
||||||
10
|
|
||||||
9
|
|
||||||
0
|
0
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
@ -82,9 +73,6 @@ Europe/Berlin
|
|||||||
10
|
10
|
||||||
10
|
10
|
||||||
10
|
10
|
||||||
9
|
|
||||||
9
|
|
||||||
9
|
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
|
@ -7,44 +7,6 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
for tz in Asia/Tehran UTC Canada/Atlantic Europe/Berlin
|
for tz in Asia/Tehran UTC Canada/Atlantic Europe/Berlin
|
||||||
do
|
do
|
||||||
echo "$tz"
|
echo "$tz"
|
||||||
TZ=$tz $CLICKHOUSE_LOCAL --multiline --multiquery "
|
TZ=$tz $CLICKHOUSE_LOCAL -mn < ${CUR_DIR}/02373_datetime64_monotonicity.queries
|
||||||
drop table if exists dt64_monotonicity_test;
|
|
||||||
drop table if exists dt64_monotonicity_test_string;
|
|
||||||
CREATE TABLE dt64_monotonicity_test (date_time DateTime64(3, 'Europe/Berlin'), id String) ENGINE = MergeTree PARTITION BY toDate(date_time, 'Europe/Berlin') ORDER BY date_time;
|
|
||||||
insert into dt64_monotonicity_test select toDateTime64('2020-01-01 00:00:00.000', 3) + number, '' from numbers(10);
|
|
||||||
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime(date_time) >= toDateTime('2020-01-01 00:00:00') SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= '2020-01-01 00:00:01.111' SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= '2020-01-01 00:00:00.000' SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= toDateTime64('2020-01-01 00:00:00.000001', 3) SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= toDateTime64('2020-01-01 00:00:00.000001', 3, 'Europe/Berlin') SETTINGS force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= toDateTime64('2020-01-01 00:00:00.000001', 6) SETTINGS force_index_by_date = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= toDateTime64('2020-01-01 00:00:00.000001', 6, 'Europe/Berlin') SETTINGS force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) >= toDateTime64('2020-01-01 00:00:00.000001', 6) SETTINGS force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) <= toDateTime64('2020-01-01 00:00:00.000001', 3, 'Europe/Berlin') settings force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) <= toDateTime64('2020-01-01 00:00:00.000001', 3) settings force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) = toDateTime64('2020-01-01 00:00:00.000000', 6);
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 3) = toDateTime64('2020-01-01 00:00:00.000000', 6, 'Europe/Berlin');
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 6) = toDateTime64('2020-01-01 00:00:00.000000', 6) settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 6) = toDateTime64('2020-01-01 00:00:00.000001', 6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 6) > toDateTime64('2020-01-01 00:00:00.000001', 6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 6) >= toDateTime64('2020-01-01 00:00:00.000001', 6, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 6) >= toDateTime64('2020-01-01 00:00:00.000001', 6) settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 0) >= toDateTime64('2020-01-01 00:00:00.000001', 0, 'Europe/Berlin') settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 0) >= toDateTime64('2020-01-01 00:00:00.000001', 0) settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 0) >= '2020-01-01 00:00:00' settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
SELECT count() FROM dt64_monotonicity_test WHERE toDateTime64(date_time, 0) >= '2020-01-01 00:00:01.1' settings force_index_by_date = 1, force_primary_key = 1;
|
|
||||||
|
|
||||||
create table dt64_monotonicity_test_string(date_time String, x String) Engine=MergeTree order by date_time;
|
|
||||||
insert into dt64_monotonicity_test_string select '2020-01-01 00:00:00.000000001', '' from numbers(1);
|
|
||||||
insert into dt64_monotonicity_test_string select '2020-01-01 00:00:00.000', '' from numbers(10);
|
|
||||||
|
|
||||||
SELECT count() FROM dt64_monotonicity_test_string WHERE toDateTime64(date_time,9) = '2020-01-01 00:00:00.000000000';
|
|
||||||
SELECT count() FROM dt64_monotonicity_test_string WHERE toDateTime64(date_time,3) = '2020-01-01 00:00:00.000000001';
|
|
||||||
SELECT count() FROM dt64_monotonicity_test_string WHERE toDateTime64(date_time,9) = '2020-01-01 00:00:00';
|
|
||||||
|
|
||||||
drop table dt64_monotonicity_test;
|
|
||||||
drop table dt64_monotonicity_test_string;
|
|
||||||
"
|
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
7385
|
|
||||||
7385
|
|
||||||
7385
|
|
||||||
7385
|
|
||||||
86401
|
|
||||||
86401
|
|
@ -1,12 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS test;
|
|
||||||
CREATE TABLE test (d DateTime, PRIMARY KEY (d));
|
|
||||||
INSERT INTO test SELECT toDateTime('2024-01-01') + number FROM numbers(1e6);
|
|
||||||
SET max_rows_to_read = 10000;
|
|
||||||
SELECT count() FROM test WHERE d <= '2024-01-01 02:03:04';
|
|
||||||
SELECT count() FROM test WHERE d <= toDateTime('2024-01-01 02:03:04');
|
|
||||||
SELECT count() FROM test WHERE d <= toDateTime64('2024-01-01 02:03:04', 0);
|
|
||||||
SELECT count() FROM test WHERE d <= toDateTime64('2024-01-01 02:03:04', 3);
|
|
||||||
SET max_rows_to_read = 100_000;
|
|
||||||
SELECT count() FROM test WHERE d <= '2024-01-02';
|
|
||||||
SELECT count() FROM test WHERE d <= toDate('2024-01-02');
|
|
||||||
DROP TABLE test;
|
|
Loading…
Reference in New Issue
Block a user