Skip to content

Instantly share code, notes, and snippets.

@sundy-li
Created January 5, 2024 02:26
Show Gist options
  • Save sundy-li/2a470c3c9be55d3c169ed5d849141332 to your computer and use it in GitHub Desktop.
Save sundy-li/2a470c3c9be55d3c169ed5d849141332 to your computer and use it in GitHub Desktop.
1brc-databend.sh
## install databend
wget "https://github.com/datafuselabs/databend/releases/download/v1.2.279/databend-v1.2.279-x86_64-unknown-linux-musl.tar.gz"
tar -xzvf databend-v1.2.279-x86_64-unknown-linux-musl.tar.gz
time bin/databend-query local --query """
CREATE FILE FORMAT my_format type = csv field_delimiter = ';' ;
WITH AGG AS(
select city, min(temperature) x , avg(temperature) y, max(temperature) z from(select \$1::String city, \$2::Float64 temperature from 'fs:///home/sundy/work/1brc/measurements.txt'(file_format => 'my_format'))
GROUP BY city
ORDER BY city
)
SELECT string_agg(city || '=' || CONCAT(x::String,'/', y::String,'/', z::String) || ', ')
FROM AGG;
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment