Skip to content

Conversation

@DarshBhavnani
Copy link
Contributor

This PR adds a feature to add a checkbox in import which allows to treat empty values as null
Fixes #19381

This pull request introduces a new optional feature for CSV data imports. A new checkbox, Import empty values as NULL, has been added to the import settings. When this option is selected, the system will now treat any empty field in the CSV file as a SQL NULL value during the import.

Previously, empty fields were imported as empty strings (''), which could cause issues with database constraints and data integrity for columns intended to be nullable. This enhancement provides users with greater control over their imported data, allowing for more precise data representation.

The changes ensure consistent behavior for both new table creation (the "analyze" mode) and importing into existing tables.

- Adds a new "Import empty values as NULL" checkbox to the CSV import options. When enabled, this setting will convert any empty string values in the imported data to the SQL `NULL` value.

- This enhancement ensures that empty fields are not stored as empty strings, which is crucial for columns where a true `NULL` value is required or expected. The logic is applied to both the table analysis and data insertion phases, providing consistent behavior when creating new tables or appending to existing ones.

Signed-off-by: Darsh Bhavnani <darshbhavnani@gmail.com>
Signed-off-by: Darsh Bhavnani <darshbhavnani@gmail.com>
By removing this, import automatically treats null string as null value

Signed-off-by: Darsh Bhavnani <darshbhavnani@gmail.com>
@DarshBhavnani DarshBhavnani force-pushed the enhancement/csv-empty-to-null branch from e0f198f to c9906ba Compare August 8, 2025 16:09
Signed-off-by: Darsh Bhavnani <darshbhavnani@gmail.com>
@liviuconcioiu
Copy link
Contributor

Thank you @DarshBhavnani! It works as intended.

Before:

before

After:

after1

After (with Import empty values as NULL checked):

after2

Copy link
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

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

We could have a test for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make empty values NULL when importing a CSV file

3 participants