clickhouse-rs icon indicating copy to clipboard operation
clickhouse-rs copied to clipboard

Support for columnar function on insert

Open volfco opened this issue 6 years ago • 0 comments

Bad title, but basically I would like the ability to wrap a column's values with a function on insert.

Right now the following code would result in a query like INSERT INTO table (addresses) VALUES ("192.168.107.9"), ("192.168.45.8")

let block = Block::new()
        .column("addresses",  vec!["192.168.107.9", "192.168.45.8"]);

I would like the ability to wrap the values in a, for example, toIPv4 function. So the following code would produce a query like INSERT INTO table (addresses) VALUES (toIPv4("192.168.107.9")), (toIPv4("192.168.45.8"))

let block = Block::new()
        .column("addresses",  vec!["192.168.107.9", "192.168.45.8"]);
block.column_function("addresses", "toIPv4");

This could also allow having a column populated by just a function, like having a Timestamp column populated by the now() function

volfco avatar Nov 10 '19 17:11 volfco