Skip to content

[source-postgres] add optional for all array schemabuilder - #41654

Merged
Xiaohan Song (xiaohansong) merged 7 commits into
masterfrom
oncall-5498
Jul 15, 2024
Merged

Xiaohan Song (xiaohansong) merged 7 commits into
masterfrom
oncall-5498

Conversation

@xiaohansong

@xiaohansong Xiaohan Song (xiaohansong) commented Jul 12, 2024 •

Copy link
Copy Markdown
Contributor

What

fixes https://github.com/airbytehq/oncall/issues/5498

Schema does not allow NULL value for array. Not 100% confident it will resolve the oncall issue, but nevertheless we should allow null value in user's array table.

How

We defined a converter for array timestamp.

Because on kafka the schema is not marked as optional:

https://github.com/a0x8o/kafka/blob/master/connect/api/src/main/java/org/apache/kafka/connect/data/SchemaBuilder.java#L361

and thus it will be thrown as error here:

https://github.com/a0x8o/kafka/blob/master/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java#L218

Thus, the fix should be changing in PostgresConverter.java to SchemaBuilder.array(OPTIONAL_STRING_SCHEMA).optional()

The problem I haven't figured out is user does not have NULL value - I wonder if that is caused by deletion change event?

Review guide

User Impact

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

@vercel

vercel Bot commented Jul 12, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 5:59pm

@postamar Marius Posta (postamar) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change seems harmless enough but I'm not sure this will fix the issue. My impression was that we already have a datatype test case with a TIMESTAMP[] column which contains an array value with a NULL element, and that this test case gets exercised with debezium in a CDC-variant of the test suite. I may be wrong.

@xiaohansong

Copy link
Copy Markdown
Contributor Author

Marius Posta (@postamar) Thanks for reviewing!

I checked test - we only have PostgresSourceOperationsTest which only tests for non debezium converter (debezium use PostgresConverter). Also, this is to prevent the entire array is null; elements in array should not trigger this problem because we define the schema as OPTIONAL_STRING_SCHEMA which already declared optional properties.

I'm not sure if that could fix user's problem - as they claimed they do not have any NULL value but we are seeing null value on our side. My guess is the deletion event could create such value but that's just a pure guess!

@postamar

Copy link
Copy Markdown
Contributor

I thought that CdcWalLogsPostgresSourceDatatypeTest would test datatypes by consuming table records via CDC. It's kind of hard to figure out just what that test does exactly so I wouldn't be surprised to be wrong!

@xiaohansong
Xiaohan Song (xiaohansong) merged commit e1c1944 into master Jul 15, 2024
@xiaohansong
Xiaohan Song (xiaohansong) deleted the oncall-5498 branch July 15, 2024 18:13
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 connectors/source/postgres

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants