JP Armstrong

DuckDB client API for KDB/Q

Duckdb is an feature-rich open source analytical query engine and database system. It's similar to KDB/Q in many respects and has additional features not yet present in KDB such as executing SQL queries directly on csv/parquet files stored on AWS S3 buckets.

Leveraging KDB's foreign functions support, I've created a library called qduck that wraps DuckDB C library and convert's its output to native KTables.

Here's an example of pulling CSV directly from a URL and loading it into KDB.

q)x)SELECT * FROM 'https://datahub.io/core/inflation/_r/-/data/inflation-gdp.csv' WHERE "Country Code" = 'USA' ORDER BY Year DESC LIMIT 10;
Country       Country Code Year Inflation
-----------------------------------------
United States USA          2023 4.116338 
United States USA          2022 8.0028   
United States USA          2021 4.697859 
United States USA          2020 1.233584 
United States USA          2019 1.81221  
United States USA          2018 2.442583 
United States USA          2017 2.13011  
United States USA          2016 1.261583 
United States USA          2015 0.1186271
United States USA          2014 1.622223 
/ to set a variable with query results
q)t:.x.e "SELECT * FROM 'https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2025-01.parquet';"
q)count t
3475226