New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Querying ReplicatedSummingMergeTree table through Distribution table with condition on DateTime64
column with lesser/greater than subquery result returns results only from single shard
#50868
Comments
Not related to ReplicatedSummingMergeTree. simpler: CREATE TABLE t ( dt64 DateTime64(3, 'UTC') ) ENGINE Memory as select '1686036919.123';
select * from remote('127.0.0.1', currentDatabase(), t) where dt64 > (select toDateTime64(0, 3));
┌────────────────────dt64─┐
│ 2023-06-06 07:35:19.123 │
└─────────────────────────┘
set prefer_localhost_replica=0;
select * from remote('127.0.0.1', currentDatabase(), t) where dt64 > (select toDateTime64(0, 3));
0 rows in set. Elapsed: 0.007 sec. WA (assumeNotNull): select * from remote('127.0.0.1', currentDatabase(), t) where dt64 > assumeNotNull((select toDateTime64(0, 3)));
┌────────────────────dt64─┐
│ 2023-06-06 07:35:19.123 │
└─────────────────────────┘ v21.9.1.8000-prestable.md:* Now, scalar subquery always returns |
Seems the issue is in DateTime64 select *, (select toDateTime64(0, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=1;
┌─dummy─┬─────────────_subquery13─┐
│ 0 │ 1970-01-01 00:00:00.000 │
└───────┴─────────────────────────┘
select *, (select toDateTime64(0, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=0;
┌─dummy─┬─_subquery14─┐
│ 0 │ ᴺᵁᴸᴸ │
└───────┴─────────────┘ select *, (select toDateTime64(-111111111, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=1;
┌─dummy─┬─────────────_subquery15─┐
│ 0 │ 1966-06-24 23:48:09.000 │
└───────┴─────────────────────────┘
select *, (select toDateTime64(-111111111, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=0;
┌─dummy─┬─_subquery16─┐
│ 0 │ ᴺᵁᴸᴸ │
└───────┴─────────────┘ cc @rschu1ze |
@den-crane any idea why it seems to be working fine with |
it's not. Test better. |
It happens because it is forbidden to parse String->DateTime(64) if its length less than 4:
DateTime64 is generally a modification of Decimal type. Looks like it is implicitly represented as string when querying to/from a remote node. Changing this may affect the precision. The same queries will work for DateTime because they are built on top of Integer, not Decimal. |
Describe what's wrong
When querying a table using
ReplicatedSummingMergeTree
engine through Distributed table with condition onDateTime64
column with lesser/greater than subquery results ClickHouse returns results only from single shard.Example query:
select * from gl_test.test_smt_d tsd where dt64 > (select toDateTime64(0, 3, 'UTC'));
Does it reproduce on recent release?
Unknown I have only access to version
22.8.17.17
How to reproduce
ClickHouse installation with at least 2 shards.
Expected behavior
select * from gl_test.test_smt_d tsd where dt64 > (select toDateTime64(0, 3, 'UTC'));
will return row from second shardError message and/or stacktrace
N/A
Additional context
I have also tested with different conditional operator and with different column types:
I have also tested with
ReplicatedMergeTree
engine:The text was updated successfully, but these errors were encountered: