This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Textplot is a DuckDB extension that provides text-based data visualization functions. It's a C++ extension built using the DuckDB extension template and CI tools, creating ASCII/Unicode charts directly from SQL queries.
# Build release version
VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake GEN=ninja make release
# Build debug version
VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake GEN=ninja make debug
# Run tests (requires build first)
make test # runs against release build
make test_debug # runs against debug buildThe build uses CMake under the hood. Build outputs go to build/release/ or build/debug/.
All extension functions should be documented inside of DuckDB with CreateScalarFunctionInfo or CreateAggregateFunctionInfo or the appropriate type for the function. This documentation of the function should include examples, parameter types and parameter names. The function should be categorized.
When making changes the version should always be updated to the current date plus an ordinal counter in the form of YYYYMMDDCC.
src/textplot_extension.cpp- Registers all scalar functions with DuckDB viaLoadInternal()
Each visualization function has a corresponding implementation file:
| Function | Files | Purpose |
|---|---|---|
tp_bar() |
textplot_bar.cpp/.hpp |
Horizontal bar charts with thresholds and colors |
tp_density() |
textplot_density.cpp/.hpp |
Density plots/histograms from arrays |
tp_sparkline() |
textplot_sparkline.cpp/.hpp |
Compact trend lines with multiple modes |
tp_qr() |
textplot_qr.cpp/.hpp |
QR code generation |
Each function follows the DuckDB scalar function pattern:
Textplot*Bind()- Validates and binds arguments at plan timeTextplot*()- Executes the function at runtime- Functions accept named parameters (e.g.,
width := 20,style := 'ascii')
src/- C++ source filessrc/include/- Header filestest/sql/- SQLLogicTest files (.testextension)duckdb/- DuckDB submodule (git submodule)extension-ci-tools/- Build system submodule
Tests use DuckDB's SQLLogicTest format in test/sql/. See https://duckdb.org/dev/sqllogictest/intro.html for syntax.
This extension uses vcpkg for dependency management. The vcpkg.json in the project root defines dependencies, and extension_config.cmake configures the extension build.