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

Add tests for FORCE_NULL * and FORCE_NOT_NULL * options for COPY FROM #7812

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

naisila
Copy link
Member

@naisila naisila commented Dec 26, 2024

These options already existed in PG17, and we support them and have tests for them in multi_copy.sql.

In PG17, their capability was extended to specify ALL columns at once using *.
Citus performs the COPY correctly, as is validated by the added tests in this PR.

Relevant PG commit:
postgres/postgres@f6d4c9cf1

Copy-pasting from Postgres documentation what these options do, such that the reviewer may better understand the tests added:

FORCE_NOT_NULL: Do not match the specified columns' values against the null string. In the default case where the null string is empty, this means that empty values will be read as zero-length strings rather than nulls, even when they are not quoted. If * is specified, the option will be applied to all columns. This option is allowed only in COPY FROM, and only when using CSV format.

FORCE_NULL: Match the specified columns' values against the null string, even if it has been quoted, and if a match is found set the value to NULL. In the default case where the null string is empty, this converts a quoted empty string into NULL. If * is specified, the option will be applied to all columns. This option is allowed only in COPY FROM, and only when using CSV format.

FORCE_NULL and FORCE_NOT_NULL can be used simultaneously on the same column. This results in converting quoted null strings to null values and unquoted null strings to empty strings.

Explain it to me like I'm a 5-year-old, for a text column:
FORCE_NULL looks for empty strings and registers them as NULL
FORCE_NOT_NULL looks for null values and registers them as empty strings.

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-13.0@d682bf0). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff               @@
##             release-13.0    #7812   +/-   ##
===============================================
  Coverage                ?   89.63%           
===============================================
  Files                   ?      274           
  Lines                   ?    59723           
  Branches                ?     7451           
===============================================
  Hits                    ?    53534           
  Misses                  ?     4057           
  Partials                ?     2132           

These options already existed in PG17, and we have support them
and have tests for them in multi_copy.sql.

In PG17, their capability was extended to specify ALL columns
at once using *.
Citus performs the COPY correctly, as is validated by the added
tests in this PR.

Relevant PG commit:
postgres/postgres@f6d4c9cf1
@naisila naisila force-pushed the naisila/pg17_copy_forcenull branch from 87ea9dc to 4c8fcc5 Compare December 26, 2024 12:40
@naisila naisila merged commit b4cc721 into release-13.0 Dec 26, 2024
149 of 157 checks passed
@naisila naisila deleted the naisila/pg17_copy_forcenull branch December 26, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants