Skip to content

Creating and dropping a macro in same txn triggers assertion #744

@Alex-Monahan

Description

@Alex-Monahan

What happens?

When creating and dropping a macro within a transaction, an assertion error is thrown (on a debug build). I didn't see any tests that tested that exact combination of events.

I am not sure how common this would be. One scenario that I could see it being useful is if you wanted to add or customize a macro just for a specific operation and not interfere with other ongoing operations. (For example, add a macro just for sorting a specific way during an inline flush, then removing that macro before committing).

To Reproduce

This test case will trigger the error in a debug build.

require ducklake

require parquet

test-env DUCKLAKE_CONNECTION __TEST_DIR__/{UUID}.db

statement ok
ATTACH 'ducklake:${DUCKLAKE_CONNECTION}' AS ducklake (DATA_PATH '__TEST_DIR__/create_then_drop_macro/')

statement ok
USE ducklake;

statement ok
BEGIN

statement ok
CREATE MACRO zip_varchar(i, j, num_chars := 6) AS (
    -- By default using 6 characters from each string so that
    -- if data is ASCII, we can fit it all in 12 bytes so that it is stored inline
    -- rather than requiring a pointer
    [
	   list_value(z[1], z[2])
	   FOR z
	   IN list_zip(
		  substr(i, 1, num_chars).rpad(num_chars, ' ').string_split(''),
		  substr(j, 1, num_chars).rpad(num_chars, ' ').string_split('')
	   )
    ].flatten().array_to_string('')
);

# Test that the macro is working as intended independently of sorting
query III
SELECT
    'ABC' AS i,
    'XYZ' AS j,
    zip_varchar(i, j, num_chars := 3) AS zipped_varchar;
----
ABC	XYZ	AXBYCZ

statement ok
DROP MACRO zip_varchar

# Error happens here
statement ok
COMMIT

OS:

MacOS

DuckDB Version:

1.5

DuckLake Version:

84636fe

DuckDB Client:

CLI

Hardware:

No response

Full Name:

Alex Monahan

Affiliation:

MotherDuck

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

I have tested with a source build

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