Skip to content
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

Fix "DB::Exception: Block structure mismatch in UNION stream: different number of columns" #2393

Closed
wants to merge 2 commits into from

Conversation

chenxing-xc
Copy link
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

I encounter the following failure, and think it's a bug. The version I am using is stable 1.1.54380, and could also reproduce this problem in main branch.

== How to reproduce:

  • Setup a cluster with more than one shards
  • create mergetree table and distributed table
    CREATE TABLE default.t ( id Int64, p_date Date) ENGINE = MergeTree PARTITION BY p_date ORDER BY id SETTINGS index_granularity = 8192
    CREATE TABLE default.t_all ( id Int64, p_date Date) ENGINE = Distributed(xxx, default, t, intHash64(id))
  • client connect to one of shard in the cluster, and issue the following statement, and could see the problem:
    ------- :) select id from t_all where p_date='2018-01-01' limit 1

SELECT id
FROM t_all
WHERE p_date = '2018-01-01'
LIMIT 1

Received exception from server (version 1.1.54382):
Code: 171. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Block structure mismatch in UNION stream: different number of columns:
id Int64 Int64(size = 0)
id Int64 Int64(size = 0), p_date Date UInt16(size = 0).

== Problem analysis:
After predicate is moved to prewhere expression, the rule to deduce columns in the result stream should be adjusted, otherwise, we should keep the PROJECT action generated by the original prewhere expression which help deduce correct stream header(block's columns).

@zhang2014
Copy link
Contributor

#2226 seems like a more complete solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants