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

Source Posgres: [CDC] allow null values for columns #13016

Merged
merged 3 commits into from
May 27, 2022

Conversation

yurii-bidiuk
Copy link
Contributor

What

Fixes #8557

How

Added 'null' values to shema building.
Before schema for column looked like { "type": "string" }
Now: { "type": [ "string", null ] }

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

There is no user impact

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@github-actions github-actions bot added area/connectors Connector related issues area/documentation Improvements or additions to documentation labels May 19, 2022
@yurii-bidiuk yurii-bidiuk changed the title Source Posgrec: [CDC] allow null values for columns Source Posgres: [CDC] allow null values for columns May 19, 2022
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented May 23, 2022

/test connector=connectors/source-postgres

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2371412185
✅ connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2371412185
No Python unittests run

@alexandertsukanov
Copy link
Contributor

LGTM

Copy link
Contributor

@alexandr-shegeda alexandr-shegeda left a comment

Choose a reason for hiding this comment

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

LGTM. we can proceed with publishing and merging without airbyte review

@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/8557-src-postgres-fix-bug branch from f4bd469 to 17e3bf1 Compare May 24, 2022 16:23
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/8557-src-postgres-fix-bug branch from 17e3bf1 to 2e90b77 Compare May 24, 2022 16:25
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented May 24, 2022

/publish connector=connectors/source-postgres

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2379210312
❌ Failed to publish connectors/source-postgres
❌ Couldn't auto-bump version for connectors/source-postgres

@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets May 24, 2022 16:27 Inactive
@grishick
Copy link
Contributor

If I understand the changes correctly, this will make all Date, Text, and Money fields nullable (optional). I don't think that's the correct change though, because it will also allow non-nullable columns to be NULLs. Could we use RelationalColumn::isOptional to detect if a column is nullable?

@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented May 25, 2022

/test connector=connectors/source-postgres

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2382689650
✅ connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2382689650
No Python unittests run

Build Passed

Test summary info:

All Passed

@yurii-bidiuk
Copy link
Contributor Author

@grishick
I tested these changes and it doesn't break any logic now. If I add optional only for nullable fields it will produce #8557. The reason is that delete event produces a message with all fields set as null [1, null, null, null] and if some of these fields has NOT NULL constrain, we will get #8557

@alexandr-shegeda alexandr-shegeda marked this pull request as ready for review May 26, 2022 15:39
@grishick
Copy link
Contributor

@grishick I tested these changes and it doesn't break any logic now. If I add optional only for nullable fields it will produce #8557. The reason is that delete event produces a message with all fields set as null [1, null, null, null] and if some of these fields has NOT NULL constrain, we will get #8557

OK. Thank you for explaining that. For posterity, please add a comment in the code explaining why it is important to keep all fields NULL-able for CDC.

@grishick
Copy link
Contributor

grishick commented May 27, 2022

/publish connector=connectors/source-postgres run-tests=false

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2397842913
🚀 Successfully published connectors/source-postgres
🚀 Auto-bumped version for connectors/source-postgres
✅ connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2397842913

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets May 27, 2022 17:57 Inactive
@grishick grishick merged commit fed651b into master May 27, 2022
@grishick grishick deleted the bidiuk/8557-src-postgres-fix-bug branch May 27, 2022 20:45
@grishick
Copy link
Contributor

I reran the build and tests locally to make sure they pass.

@yurii-bidiuk
Copy link
Contributor Author

@grishick thank you for helping with this issue

jscottpolevault pushed a commit to jscottpolevault/airbyte that referenced this pull request Jun 1, 2022
* [cdc] source postgres: add optional to schema fields

* bump version

* auto-bump connector version

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation
Projects
None yet
5 participants