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

Allow TTL to support nested functions #63800

Open
avinzhang opened this issue May 15, 2024 · 0 comments
Open

Allow TTL to support nested functions #63800

avinzhang opened this issue May 15, 2024 · 0 comments
Labels

Comments

@avinzhang
Copy link
Contributor

Allow support of nested function in TTL statement

Sample query
ALTER TABLE test.ttl_rollup_test MODIFY TTL -- after 2 days: keep only the latest best price for each site-product-combination local_date + INTERVAL 2 DAY GROUP BY site_id, product_id SET local_date = max(local_date), event_time = max(event_time), price = argMax(price, concat(cast(event_time AS varchar), cast((100_000_000_000 - price) AS varchar))), shop_id = argMax(shop_id, concat(cast(event_time AS varchar), cast((100_000_000_000 - price) AS varchar))), merchant_id = argMax(merchant_id, concat(cast(event_time AS varchar), cast((100_000_000_000 - price) AS varchar))), offer_key = argMax(offer_key, concat(cast(event_time AS varchar), cast((100_000_000_000 - price) AS varchar)));

Currently the above statement will throw an error
com.clickhouse.client.ClickHouseException: Code: 10. DB::Exception: Not found column concat(CAST(event_time, 'varchar'), CAST(minus(100000000000, price), 'varchar')) in block. There are only columns: local_date, offer_key, shop_id, price, site_id, product_id, merchant_id, event_time: While executing TTL. (NOT_FOUND_COLUMN_IN_BLOCK) (version 23.9.6.20 (official build))

This works when just doing a select like this
select argMax(price, concat(cast(event_time AS varchar), cast((100_000_000_000 - price) AS varchar)))

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

No branches or pull requests

1 participant