Skip to content

Fix empty table insert requirement#630

Merged
Tmonster merged 1 commit intoduckdb:v1.4-andiumfrom
smaheshwar-pltr:sm/empty-table-insert-requirement
Jan 14, 2026
Merged

Fix empty table insert requirement#630
Tmonster merged 1 commit intoduckdb:v1.4-andiumfrom
smaheshwar-pltr:sm/empty-table-insert-requirement

Conversation

@smaheshwar-pltr
Copy link
Copy Markdown
Contributor

@smaheshwar-pltr smaheshwar-pltr commented Dec 17, 2025

Closes #631

@smaheshwar-pltr
Copy link
Copy Markdown
Contributor Author

@Tmonster maybe, mind taking a look?

@Tmonster
Copy link
Copy Markdown
Collaborator

Tmonster commented Jan 2, 2026

Hi @smaheshwar-pltr,

Thanks for the PR! Looks good to me. The failing test can be fixed with an order by all statement.
Also can you add a similar test for polaris with the following code?

# name: test/sql/local/irc/test_polaris_concurrent_insert.test
# description: Test concurrent inserts to a newly created table with no snapshots
# group: [insert]

require-env POLARIS_CLIENT_ID

require-env POLARIS_CLIENT_SECRET

require-env POLARIS_SERVER_AVAILABLE

require avro

require parquet

require httpfs

require iceberg

require aws

# Do not ignore 'HTTP' error messages!
set ignore_error_messages

statement ok
create secret polaris_secret (
	TYPE ICEBERG,
	CLIENT_ID '${POLARIS_CLIENT_ID}',
	CLIENT_SECRET '${POLARIS_CLIENT_SECRET}',
	ENDPOINT 'http://0.0.0.0:8181/api/catalog'
);

statement ok
attach 'quickstart_catalog' as my_datalake (
	type ICEBERG,
	ENDPOINT 'http://0.0.0.0:8181/api/catalog'
);

statement ok
DROP TABLE IF EXISTS my_datalake.default.concurrent_new_table_test;

statement ok
CREATE TABLE my_datalake.default.concurrent_new_table_test (id INTEGER, name VARCHAR);

# con1 starts a transaction and inserts
statement ok con1
begin

statement ok con1
INSERT INTO my_datalake.default.concurrent_new_table_test VALUES (1, 'con1');

# con2 starts a transaction and inserts
statement ok con2
begin

statement ok con2
INSERT INTO my_datalake.default.concurrent_new_table_test VALUES (2, 'con2');

# con2 commits first
statement ok con2
commit

# con1 should fail because con2 already added a snapshot
statement error con1
commit
----
<REGEX>:.*Requirement failed: branch main was created concurrently.*

# only con2's data is in the table
query II
SELECT * FROM my_datalake.default.concurrent_new_table_test ORDER BY id;
----
2	con2

statement ok
DROP TABLE my_datalake.default.concurrent_new_table_test;


# attach with support stage create as false
# polaris is currently file backed in tests, so folders are not automatically
# created when creating a table with stage_create=true
statement ok
attach or replace 'quickstart_catalog' as my_datalake (
	type ICEBERG,
	ENDPOINT 'http://0.0.0.0:8181/api/catalog',
	SUPPORT_NESTED_NAMESPACES true,
	support_stage_create false
);

statement ok
DROP TABLE IF EXISTS my_datalake.default.concurrent_new_table_test;

statement ok
CREATE TABLE my_datalake.default.concurrent_new_table_test (id INTEGER, name VARCHAR);

# con1 starts a transaction and inserts
statement ok con1
begin

statement ok con1
INSERT INTO my_datalake.default.concurrent_new_table_test VALUES (1, 'con1');

# con2 starts a transaction and inserts
statement ok con2
begin

statement ok con2
INSERT INTO my_datalake.default.concurrent_new_table_test VALUES (2, 'con2');

# con2 commits first
statement ok con2
commit

# con1 should fail because con2 already added a snapshot
statement error con1
commit
----
<REGEX>:.*Requirement failed: branch main was created concurrently.*

# only con2's data is in the table
query II
SELECT * FROM my_datalake.default.concurrent_new_table_test ORDER BY id;
----
2	con2

statement ok
DROP TABLE my_datalake.default.concurrent_new_table_test;

I've tested this and it passes locally on you branch.

And then for the spark test, can you also add a case where the catalog doesn't support stage create?

@Tmonster Tmonster merged commit e9cd4fd into duckdb:v1.4-andium Jan 14, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants