Skip to content

Instantly share code, notes, and snippets.

@Slach
Last active October 2, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Slach/8a8bb43c43b6257a013753d1ac51c978 to your computer and use it in GitHub Desktop.
Save Slach/8a8bb43c43b6257a013753d1ac51c978 to your computer and use it in GitHub Desktop.
20.8 reproduce DB::Exception: Cannot add simple transform to empty Pipe

Exception raised when we don't have data in table and have dictGet in WHERE clause steps to reproduce

docker-compose up -d
docker-compose exec clickhouse bash -c "clickhouse-client -mn --echo < /var/lib/clickhouse/user_files/success_query.sql"
docker-compose exec clickhouse bash -c "clickhouse-client -mn --echo < /var/lib/clickhouse/user_files/failed_query.sql"
diff failed_query.sql success_query.sql
less clickhouse-server.log
version: "3"
services:
clickhouse:
image: yandex/clickhouse-server:latest
ports:
- 8123:8123
- 9000:9000
volumes:
- ./dict_prod_partner_affiliate_links.txt:/var/lib/clickhouse/user_files/dict_prod_partner_affiliate_links.txt
- ./success_query.sql:/var/lib/clickhouse/user_files/success_query.sql
- ./failed_query.sql:/var/lib/clickhouse/user_files/failed_query.sql
- ./init_schema.sql:/docker-entrypoint-initdb.d/init_schema.sql
- ./:/var/log/clickhouse-server/
SELECT toDate(i.event_date) AS day,
coalesce(sum(i.cost), 0) AS pcost
FROM wister.rtb_and_mb_left_join_raw_data_buffer i
WHERE dictGet('wister.dict_prod_partner_affiliate_links','partner_id',tuple(i.code_affilie))>0
AND i.event_date >= now() - INTERVAL 30 DAY
AND i.event_date < now() - INTERVAL 7 DAY
GROUP BY day;
CREATE DATABASE IF NOT EXISTS wister;
CREATE DICTIONARY wister.dict_prod_partner_affiliate_links
(
`code_affilie` String,
`partner_id` Int32
)
PRIMARY KEY code_affilie
SOURCE(FILE(path '/var/lib/clickhouse/user_files/dict_prod_partner_affiliate_links.txt' format 'TabSeparated'))
LIFETIME(MIN 300 MAX 600)
LAYOUT(COMPLEX_KEY_HASHED());
CREATE TABLE wister.rtb_and_mb_left_join_raw_data
(
`event_date` Date DEFAULT toDate('0000-00-00'),
`import_date` DateTime DEFAULT toDateTime(now()),
`code_affilie` LowCardinality(String) DEFAULT '',
`cost` Decimal(18, 10)
)
ENGINE = ReplacingMergeTree(import_date)
PARTITION BY toYYYYMM(event_date)
ORDER BY event_date
SETTINGS index_granularity = 8192;
CREATE TABLE wister.rtb_and_mb_left_join_raw_data_buffer
(
`event_date` Date DEFAULT toDate('0000-00-00'),
`import_date` DateTime DEFAULT toDateTime(now()),
`code_affilie` String DEFAULT '',
`cost` Decimal(18, 10)
)
ENGINE = Buffer('wister', 'rtb_and_mb_left_join_raw_data', 16, 10, 60, 10, 1000, 1048576, 2097152);
INSERT INTO wister.rtb_and_mb_left_join_raw_data_buffer VALUES(toDate(now()), now(), 'code_affilie', 1);
SELECT toDate(i.event_date) AS day,
coalesce(sum(i.cost), 0) AS pcost
FROM wister.rtb_and_mb_left_join_raw_data_buffer i
WHERE dictGet('wister.dict_prod_partner_affiliate_links','partner_id',tuple(i.code_affilie))>0
AND i.event_date >= now() - INTERVAL 7 DAY
AND i.event_date < now() + INTERVAL 7 DAY
GROUP BY day;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment