Skip to content

Error: INTERNAL Error: Calling DefaultValue() on a generated column #9745

@JensonSung

Description

@JensonSung

What happens?

I clone the package and build the latest release. When executing pragma_table_info on a table with generated columns through the DuckDB CLI, an error is returned, Error: INTERNAL Error: Calling DefaultValue() on a generated column.

I've noticed that a similar bug that has been fixed in #8833.
Since we can properly return the stringified generated expression.
A suggested Fix may be removing the IF branch in the following code.

// in src/parser/column_definition.cpp
// Remove the IF branch
const unique_ptr<ParsedExpression> &ColumnDefinition::DefaultValue() const {
	if (Generated()) {
		throw InternalException("Calling DefaultValue() on a generated column");
	}
	return expression;
}

To Reproduce

create table t1 (c1 int, c2 int generated always as (c1 + 1));
SELECT * FROM pragma_table_info(t1); -- Error: INTERNAL Error: Calling DefaultValue() on a generated column

OS:

Ubuntu 22.04LTS x86

DuckDB Version:

v0.9.3-dev668 802c71d

DuckDB Client:

CLI

Full Name:

Jiansen Song

Affiliation:

Institute of Software Chinese Academy of Sciences

Have you tried this on the latest main branch?

I have tested with a main build

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • 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