Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creation of DuckDB tables with arrays of boolean, tinyint and smallint #8408

Closed

Conversation

mbasmanova
Copy link
Contributor

Creating DuckDB table with a column of type array(boolean), array(tinyint) or
array(smallint) having a mix of null and non-null array elements used to fail with

INTERNAL Error: Assertion triggered in file "/home/runner/work/velox/velox/_build/debug/_deps/duckdb-src/src/common/types/value.cpp" on line 702: values[i].type() == values[0].type()

The problem is that duckValueAt<TypeKind> template in QueryAssertions.cpp used
to convert non-null values by calling duckdb::Value(v) API, which is not defined
for bool, int8_t and int16_t. Hence, we ended up calling a version of that API
that takes int32_t and returns a value of type INTEGER. However, code for
converting null values used duckdb::Value(type) API which takes type directly
and therefore creates values of the "right" type. When array value had a mix of
null and non-null values we ended up passing a list of elements of different
types to DuckDB and hit an assertion.

A fix implemented here is to provide explicit overrides for boolean, tinyint and smallint.

This issue happens often in join fuzzer runs.

Fixes #7943

Copy link

netlify bot commented Jan 17, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 41afcd3
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/65a76c1df29cba0008abae1b

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 17, 2024
@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbasmanova thanks for the fix!

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@@ -39,6 +39,30 @@ ::duckdb::Value duckValueAt(const VectorPtr& vector, vector_size_t index) {
return ::duckdb::Value(vector->as<SimpleVector<T>>()->valueAt(index));
}

template <>
::duckdb::Value duckValueAt<TypeKind::TINYINT>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we add a test in QueryAssertionsTest

@facebook-github-bot
Copy link
Contributor

@mbasmanova merged this pull request in 82bcd39.

Copy link

Conbench analyzed the 1 benchmark run on commit 82bcd390.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nightly Join fuzzer consistent faluire 'duckdb::InternalException' values[i].type() == values[0].type()
4 participants