duckdb / duckdb_mysql

https://duckdb.org/docs/extensions/mysql
MIT License
55 stars 13 forks source link

INTERNAL Error: Primary exception: Failed to cast MySQL boolean - expected 1 byte element but got element of size %s #75

Closed cboettig closed 2 months ago

cboettig commented 3 months ago

What happens?

I am using the duckdb cli with the mysql extension to export a database from mysql to parquet. On export, I get the error:

D export database 'fbapp2024' (FORMAT PARQUET);
INTERNAL Error: Primary exception: Failed to cast MySQL boolean - expected 1 byte element but got element of size %s
Secondary exception in ExceptionFormatValue: {"exception_type":"Invalid Input","exception_message":"Invalid type specifier \"s\" for formatting a value of type int"}
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors

The error directs me to file an issue. The mysql database I am exporting has 214 tables. The error does not provide any information about which table is responsible for this internal error so I am not sure how to create a minimal reproducible example of the issue or how to proceed.

To Reproduce

I would be happy to share the full sql dump from the mysql (it's only ~100 MB compressed) if that helps to debug, but I haven't been able to reduce this to a nice minimal reproducible example because duckdb's error message gives me zero information about which of the 214 tables the export hit this error.

OS:

ubuntu

DuckDB Version:

1.0.0

DuckDB Client:

duckdb cli client

Full Name:

Carl Boettiger

Affiliation:

UC Berkeley

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?

No - Other reason (please specify in the issue body)

Did you include all code required to reproduce the issue?

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

carlopi commented 3 months ago

I think here there is for sure an error in the formatting code within the throw in duckdb/duckdb_mysql, fixing that should make the error behave slightly better. And likely there is also an expectation boolean values are a single byte, while here for some reason it's a multibyte. Also here expanding the error message would likely help in figuring out what should be done.

This likely it's placed in the duckdb/duckdb_mysql repo

Mytherin commented 3 months ago

Thanks for reporting!

I agree the error message here could be better.

Perhaps you can retry with the following settings?

SET mysql_tinyint1_as_boolean=false;
SET mysql_bit1_as_boolean=false;
cboettig commented 3 months ago

You nailed it in one go with like no information, amazing! This solved my issue. I will read https://duckdb.org/docs/extensions/mysql more closely next time!

Mytherin commented 3 months ago

I'll keep the issue open as I think the error message can definitely be improved here