{question}
How to troubleshoot and fix ERROR 1406 (22001): Leaf Error (x.x.x.x:330X): Data too long for column 'column_name' error while inserting or ingesting data?
{question}
{answer}
This is an expected error while ingesting data into the column where the length of the data inserted is greater than the maximum length defined for the particular column's data type.
Error:
mysql> INSERT INTO test_table (str_col) VALUES ("abcdefghijklmnopqrstuvwxyz");
ERROR 1406 (22001): Leaf Error (10.0.1.246:3307): Data too long for column 'str_col'
If thedata_conversion_compatibility_level
variable is set to 6.5 and above it will validate the length and, instead of truncating the data, it will throw an error as below.
If you want to avoid the error, the recommended solution is to change the datatype which has sufficient length to store the data. Also, you can decrease the data_conversion_compatibility_level
back to 6.0 which is not recommended because with this setting instead of erroring out SingleStore truncates string values when the length of the string is greater than the specified column value.
Click here to learn about data type conversion.
{answer}