The Wild

DuckDB 2 Migration Pitfalls Checklist

· 5 min read · Mammals

In this article
  1. Why DuckDB 2.0 Breaks Things
  2. Checklist Before You Upgrade
  3. Common SQL Syntax Pitfalls
  4. Type Casting and Function Changes
  5. Extension and Client API Migration
  6. Performance and Storage Considerations
  7. How to Choose Between 1.x and 2.x
  8. Frequently Asked Questions

Migrating to DuckDB 2.x is not a drop-in replacement for 1.x: the major version introduces breaking changes around SQL syntax, type casting, and extension handling. This checklist covers the most common pitfalls, with concrete examples and workarounds, so you can plan a smoother upgrade.

Why DuckDB 2.0 Breaks Things

DuckDB follows semantic versioning, so a major version bump signals intentional incompatibilities. The 2.0 release removed deprecated functions, tightened type coercion rules, and changed how some extensions are loaded. For example, the old read_csv auto-detection now fails on ambiguous column types instead of silently guessing. The team publishes a migration guide, but it assumes you know exactly which features you rely on. Most real-world breakage comes from three areas: SQL syntax changes, type casting behavior, and extension API changes.

Checklist Before You Upgrade

  1. Audit your SQL queries for deprecated functions: regexp_matches (use regexp_full_match or regexp_like), week (use weekofyear), and the old || string concatenation with non-strings (now requires explicit cast).
  2. Test type casting with a sample dataset: DuckDB 2.0 is stricter about implicit conversions, e.g., SELECT '1.5'::INT now errors instead of truncating.
  3. Check extension loading – some extensions (e.g., httpfs, parquet) are now built-in or require different install commands.
  4. Review your Python/Java client code for API changes: the Python client's duckdb.connect() now defaults to read-only if the database file exists.
  5. Run your full test suite against a 2.x beta or release candidate, not just a few smoke tests.
  6. Back up your database files – though DuckDB is file-based, a failed migration can corrupt the catalog.

Common SQL Syntax Pitfalls

The most frequently hit issue is the removal of the DISTINCT ON syntax from PostgreSQL compatibility mode – it was never officially supported in DuckDB, but 1.x tolerated it in some contexts. In 2.0, use QUALIFY ROW_NUMBER() OVER (PARTITION BY ...) instead. Another common trap: the ORDER BY clause in aggregate functions now requires explicit WITHIN GROUP for ordered-set aggregates like percentile_cont. For example, percentile_cont(0.5) WITHIN GROUP (ORDER BY x) is mandatory; the old implicit ordering is gone.

Type Casting and Function Changes

DuckDB 2.0 enforces the SQL standard more strictly. The classic example: SELECT '2023-01-01'::DATE + 1 now errors because adding an integer to a date is not defined – you must use INTERVAL '1 day' or DATE_ADD. Similarly, string-to-numeric casts no longer accept trailing whitespace by default; use TRY_CAST if you need lenient parsing. The regexp_replace function now requires the global flag as a separate argument, not as part of the pattern. Check your ETL pipelines for these patterns.

Extension and Client API Migration

Extensions like httpfs and parquet are now core features in 2.0, so you can remove INSTALL and LOAD statements. However, community extensions that were not updated will fail to load. The Python client's fetch_arrow_table() now returns a PyArrow Table with a different schema metadata format – if you rely on column names from Arrow, test carefully. The Java client also changed its connection URL handling: the ?read_only=true parameter is now required for read-only connections, whereas 1.x defaulted to read-write.

Performance and Storage Considerations

DuckDB 2.0 introduced a new on-disk format that is not backward-compatible. Once you open a database file with 2.x, you cannot open it with 1.x. The new format uses a different compression algorithm for string columns, so file sizes may change. For large databases, plan a migration window – the conversion happens on first open and can take time. Also, the default memory limit changed from 80% of RAM to 50% in some builds, so you may need to set memory_limit explicitly to avoid OOM errors on memory-constrained machines.

How to Choose Between 1.x and 2.x

If you are starting a new project, go straight to 2.x – it's the current stable release and has better SQL standard compliance. For existing production systems, do not upgrade until you have tested all critical queries. If you rely on a community extension that hasn't been updated, stay on 1.x until that extension catches up. You can also run both versions side-by-side using separate database files, but you cannot share a single file between them.

Frequently Asked Questions

Can I downgrade from DuckDB 2.x back to 1.x?

No, once a database file has been opened with 2.x, it is upgraded to the new format and cannot be read by 1.x. Always keep a backup of your original file before opening it with 2.x.

Does DuckDB 2.0 support all the SQL features of 1.x?

Mostly yes, but some deprecated features were removed. The migration guide lists them, but common ones include DISTINCT ON and implicit casts from strings to numbers. You can use SET preserve_insertion_order = false for some old behavior, but it's not a full compatibility mode.

How do I migrate my Python code to DuckDB 2.x?

Update your duckdb package to the latest 2.x version, then run your tests. The main changes are in the duckdb.connect() signature (read-only default) and the return type of fetch_arrow_table(). Also, replace any deprecated functions in your SQL strings.

Will my Parquet files work with DuckDB 2.x?

Yes, Parquet reading is fully supported and even improved in 2.0. However, the read_parquet function may now infer different types for columns with mixed data – use the columns parameter to specify types explicitly if you encounter issues.

Is there a way to test DuckDB 2.x without affecting my current setup?

Yes, you can install DuckDB 2.x in a separate virtual environment or use the CLI binary, and point it to a copy of your database file. The upgrade will happen on the copy, leaving your original intact.