timeplus-io / proton

A stream processing engine and database, and a fast and lightweight alternative to ksqlDB and Apache Flink, 🚀 powered by ClickHouse
https://timeplus.com
Apache License 2.0
1.58k stars 69 forks source link

ClickHouse External Table takes derived(aliased) column as normal, thus cause error when write to it #809

Open yaboyang opened 3 months ago

yaboyang commented 3 months ago

The ClickHouse External Table pulls metadata from ClickHouse by itself. It's convenient but it takes derived columns as normal. And it put all columns into generated insert statement, which sent to ClickHouse, though you select partial columns in proton side. And then a "No such column" error raised if there's one aliased column.

How to reproduce It should be quite clear. create table aliased_column(pk Int32, v1 Int32, v2 Int32, s Int32 alias v1 + v2) engine = MergeTree order by pk; CREATE EXTERNAL TABLE ch_test SETTINGS type='clickhouse', ... insert into ch_test (pk, v1, v2) values (1, 1, 2)

And then: Code: 16. DB::Exception: Received from localhost:8463. DB::Exception: Received from xxxx:9000. DB::Exception: No such column s in table default.aliased_column

Proton Version is 1.5.13 revision 54459