Skip to content

Adding new JSON column fails #517

@guitcastro

Description

@guitcastro

What happens?

If you try to add a new column with JSON data type it fails with Invalid Input Error: Unsupported user-defined type

To Reproduce

Just run the following script:

ATTACH 'ducklake:/tmp/test.db' AS test_db;
use test_db;

-- DuckDB JSON Column Issue Reproduction
-- This script demonstrates the "Unsupported user-defined type" error when trying to add JSON columns to existing tables

-- Test 1: JSON columns work fine during table creation
CREATE TABLE test_json_creation (
    id BIGINT,
    status VARCHAR,
    batch_id VARCHAR,
    validation_errors JSON
);

-- Verify the table was created successfully
PRAGMA table_info(test_json_creation);

-- Test 2: Adding JSON column to existing table fails
CREATE TABLE batch_transaction_finished (
    id BIGINT,
    status VARCHAR,
    batch_id VARCHAR
);

-- Verify initial table structure
PRAGMA table_info(batch_transaction_finished);

-- This statement will fail with "Invalid Input Error: Unsupported user-defined type"
ALTER TABLE batch_transaction_finished ADD COLUMN validation_errors JSON;

-- Expected error:
-- Invalid Input Error: Unsupported user-defined type

-- Test 3: Try other column types to confirm JSON is the issue
-- These should work fine:
ALTER TABLE batch_transaction_finished ADD COLUMN created_at TIMESTAMP;
ALTER TABLE batch_transaction_finished ADD COLUMN count_field INTEGER;
ALTER TABLE batch_transaction_finished ADD COLUMN description VARCHAR;

-- But JSON fails:
-- ALTER TABLE batch_transaction_finished ADD COLUMN metadata JSON;

-- Cleanup
DROP TABLE IF EXISTS test_json_creation;
DROP TABLE IF EXISTS batch_transaction_finished;

-- Summary:
-- - Creating tables with JSON columns works: ✓
-- - Adding JSON columns to existing tables via ALTER TABLE fails: ✗
-- - Adding other column types to existing tables works: ✓
-- - This appears to be a limitation/bug in DuckDB's ALTER TABLE JSON support

OS:

mac os aarch64

DuckDB Version:

1.4.1

DuckLake Version:

0.3

DuckDB Client:

Java, Cli

Hardware:

No response

Full Name:

Guilherme Torres Castro

Affiliation:

Inyo

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions