/keboola-cli:duckdb-transformationfrom keboola-cli
Guides writing, optimizing, and migrating DuckDB transformations in Keboola. Covers SQL dialect, block orchestration, Parquet format, and Snowflake migration.
Ships in keboola-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Provide expertise on writing, configuring, and optimizing DuckDB transformations in Keboola Connection.
DuckDB (keboola.duckdb-transformation) is an in-process analytical database (OLAP) with columnar storage,
designed for fast SQL analytics. It is a cost-effective alternative to Snowflake for small-to-medium datasets.
Status: BETA --- breaking changes may occur.
Key advantages:
keboola.duckdb-transformation
{
"parameters": {
"blocks": [
{
"name": "Block Name",
"codes": [
{
"name": "Script Name",
"script": [
"CREATE TABLE \"output\" AS",
"SELECT * FROM \"input_table\";"
]
}
]
}
],
"threads": 4,
"max_memory_mb": 2048,
"image_tag": "parquet",
"dtypes_infer": false
},
"storage": {
"input": {
"tables": [
{
"source": "in.c-bucket.table",
"destination": "input_table"
}
]
},
"output": {
"tables": [
{
"source": "output",
"destination": "out.c-bucket.result"
}
]
}
}
}
latest (default) or pinned (e.g., 1.5.2, 1.4.4)| Backend Size | Memory | Recommended For |
|---|---|---|
| XSmall | 8 GB | Small datasets, testing |
| Small (default) | 16 GB | Most use cases |
| Medium | 32 GB | Large datasets (5 GB+) |
| Large | 113.6 GB | Very large datasets (10 GB+) |
Start with Small, scale up as needed. Dynamic backends are not available on Free/Pay As You Go plans.
DuckDB automatically detects available CPU and memory. Manual override via threads and max_memory_mb parameters.
Enable Parquet for significantly better performance with large datasets:
Recommendation: Always use Parquet for datasets > 1 GB.
Configuration: set "image_tag": "parquet" or toggle Use parquet for input tables in UI.
Keboola Storage tables can be non-typed (all columns as VARCHAR). When enabled, DuckDB infers
actual types (INTEGER, FLOAT, DATE, etc.) so aggregate functions and type-specific operations
work without manual casting.
Without inference: SUM("amount") fails because amount is VARCHAR.
With inference: SUM("amount") works because DuckDB detects it as numeric.
Four debugging actions available without running the full transformation:
syntax_check --- validate SQL syntax without executionlineage_visualization --- markdown diagram of data dependenciesexecution_plan_visualization --- planned execution order with blocks and batchesexpected_input_tables --- list of expected input tables based on SQL analysisEach SQL statement MUST be terminated with a semicolon (;). Multiple statements in a single
script must be properly separated:
-- Correct: each statement ends with a semicolon
CREATE TABLE "output_a" AS SELECT * FROM "input_a";
CREATE TABLE "output_b" AS SELECT * FROM "input_b";
Missing semicolons cause syntax errors.
Table names:
MyTable → mytable)"MyTable" stays MyTable)Column names:
SELECT columnName and SELECT ColumnName refer to different columnsThis is different from Snowflake (unquoted → uppercase, quoted columns case-insensitive).
Best practice: Use consistent lowercase naming or always quote identifiers.
For non-typed Storage tables, use safe casting patterns:
-- Safe: handles empty strings without errors
TRY_CAST(NULLIF("column", '') AS DATE)
TRY_CAST(NULLIF("column", '') AS DOUBLE)
TRY_CAST(NULLIF("column", '') AS INT)
-- Shorthand type cast
"column"::BOOLEAN
"column"::INTEGER
-- Regular cast
CAST("column" AS DECIMAL)
Pattern: TRY_CAST(NULLIF("col", '') AS TYPE) --- converts empty strings to NULL before
casting, avoiding errors on empty values.
Quality-of-life extensions not available in all SQL dialects:
-- GROUP BY ALL: auto-groups by all non-aggregated columns
SELECT product, category, SUM(sales) FROM orders GROUP BY ALL;
-- EXCLUDE: select all columns except specific ones
SELECT * EXCLUDE (password, ssn) FROM users;
-- ASOF JOIN: time-series data with non-matching timestamps
SELECT s.player_id, s.score, w.temperature
FROM scores s ASOF JOIN weather w ON s.score_time >= w.timestamp;
-- SUMMARIZE: quick data profiling
SUMMARIZE SELECT * FROM my_table;
For datasets > 10 GB, configure on-disk processing:
PRAGMA memory_limit='8GB';
PRAGMA temp_directory='/tmp/duckdb_temp';
PRAGMA threads=4;
PRAGMA enable_object_cache;
| Snowflake | DuckDB | Notes |
|---|---|---|
VARIANT | JSON or VARCHAR | Semi-structured data |
ARRAY | LIST | Native arrays |
OBJECT | STRUCT or JSON | Nested objects |
INTEGER | INTEGER | Same |
VARCHAR | VARCHAR | Same |
TIMESTAMP | TIMESTAMP | Same |
| Category | Snowflake | DuckDB |
|---|---|---|
| Window functions | QUALIFY ROW_NUMBER() OVER (...) = 1 | Subquery with WHERE rn = 1 |
| Null handling | NVL(a, b) | COALESCE(a, b) |
| Conditionals | IFF(cond, a, b) | CASE WHEN cond THEN a ELSE b END |
| Date add | DATEADD(day, 7, date) | date + INTERVAL '7 days' |
| Date diff | DATEDIFF(day, d1, d2) | date_diff('day', d1, d2) |
| String agg | LISTAGG(...) WITHIN GROUP (ORDER BY ...) | STRING_AGG(...) |
| Transient tables | CREATE TRANSIENT TABLE | Not supported (use regular or TEMP) |
Snowflake:
MyTable → MYTABLE)"MyTable" ≠ "MYTABLE")DuckDB:
MyTable → mytable)Migration tip: Use consistent lowercase naming: CREATE TABLE mytable ...
-- Snowflake
SELECT * FROM table QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY date DESC) = 1;
-- DuckDB
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY date DESC) AS rn
FROM table
) WHERE rn = 1;
temp.main schema (cannot specify another)memory.main.table_nameSQLGlot can automatically convert ~85% of Snowflake SQL to DuckDB syntax. However, complex queries, Snowflake-specific functions, and edge cases may not convert correctly.
Transformation Migration Component (keboola.app-transformation-migration):
Important: The automatic migration is not 100% accurate. Roughly 25% of migrated transformations will require manual adjustments --- typically:
Always review and test migrated configurations before using in production.
SUBSTRING(str, start, len)POSITION('x' IN str)CONCAT(a, b) (both handle NULL gracefully)a || b (both return NULL if any input is NULL)LIMIT nFETCH FIRST n ROWSCREATE TEMP TABLE / CREATE TEMPORARY TABLECREATE OR REPLACE TABLECREATE TABLE IF NOT EXISTSCREATE TABLE AS SELECT (CTAS)Typical transformation processing CRM data (e.g., HubSpot):
/* companies */
CREATE TABLE "out_companies" AS
SELECT
"companyId",
"name",
"website",
TRY_CAST(NULLIF("createdate", '') AS DATE) AS "createdate",
"isDeleted"::BOOLEAN AS "isDeleted"
FROM "companies";
/* contacts */
CREATE TABLE "out_contacts" AS
SELECT
"canonical_vid",
"firstname",
"lastname",
"email",
TRY_CAST(NULLIF("createdate", '') AS DATE) AS "createdate",
"hs_analytics_source" AS "email_source",
"associatedcompanyid",
"lifecyclestage"
FROM "contacts";
/* deals */
CREATE TABLE "out_deals" AS
SELECT
"dealId",
"isDeleted"::BOOLEAN AS "isDeleted",
"dealname",
TRY_CAST(NULLIF("createdate", '') AS DATE) AS "createdate",
TRY_CAST(NULLIF("closedate", '') AS DATE) AS "closedate",
"dealtype",
TRY_CAST(NULLIF("amount", '') AS DOUBLE) AS "amount",
"pipeline",
"dealstage",
"hubspot_owner_id",
"hs_analytics_source"
FROM "deals";
/* pipeline stages */
CREATE TABLE "out_stages" AS
SELECT
"stageId",
"label",
TRY_CAST(NULLIF("displayOrder", '') AS INT) AS "displayOrder",
TRY_CAST(NULLIF("probability", '') AS DOUBLE) AS "probability",
"closedWon"::BOOLEAN AS "closedWon"
FROM "pipeline_stages";
/* deals-contacts association */
CREATE TABLE "out_deals_contacts" AS
SELECT
"contact_vid",
"dealId"
FROM "deals_contacts_list";
/* activities */
CREATE TABLE "out_activities" AS
SELECT
"engagement_id",
"metadata_subject",
TRY_CAST(NULLIF("engagement_createdAt", '') AS DATE) AS "engagement_createdAt",
"metadata_durationMilliseconds",
"associations_contactIds",
"associations_dealIds",
"associations_ownerIds"
FROM "activities";
; when multiple statements in a scriptstg_, fact_, dim_ prefixes)TRY_CAST(NULLIF(...) AS TYPE) pattern for safe type conversion of potentially empty valuesChoose DuckDB for:
Choose Snowflake for:
DuckDB is NOT for transactional workloads. It is an OLAP database optimized for SELECT statements. Avoid frequent INSERT/UPDATE operations.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
duckdb, keboola, transformation, etl, sql, snowflake-migration
npx claudepluginhub keboola/ai-kit --plugin keboola-cli2 skills in this plugin
Other plugins' skills for the same job