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

Postgres source: added items for array data type #15138

Closed
wants to merge 3 commits into from

Conversation

sashaNeshcheret
Copy link
Contributor

What

Describe what the change is solving
It helps to add screenshots if it affects the frontend.

How

Describe the solution

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

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/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/platform issues related to the platform area/protocol labels Jul 29, 2022
@sashaNeshcheret sashaNeshcheret temporarily deployed to more-secrets July 29, 2022 12:00 Inactive
@sashaNeshcheret sashaNeshcheret marked this pull request as ready for review August 1, 2022 15:10
@sashaNeshcheret sashaNeshcheret requested review from a team as code owners August 1, 2022 15:10
@sashaNeshcheret
Copy link
Contributor Author

sashaNeshcheret commented Aug 1, 2022

/test connector=connectors/source-postgres

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2776068836
❌ connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/2776068836
🐛 https://gradle.com/s/tuoytmtgml5zi

Build Failed

Test summary info:

Could not find result summary

@sashaNeshcheret sashaNeshcheret temporarily deployed to more-secrets August 1, 2022 15:44 Inactive

public static final JsonSchemaType STRING = JsonSchemaType.builder(JsonSchemaPrimitive.STRING).build();
public static final JsonSchemaType NUMBER = JsonSchemaType.builder(JsonSchemaPrimitive.NUMBER).build();
public static final JsonSchemaType INTEGER = JsonSchemaType.builder(JsonSchemaPrimitive.NUMBER).withAirbyteType(AIRYBTE_INT_TYPE).build();
public static final JsonSchemaType BOOLEAN = JsonSchemaType.builder(JsonSchemaPrimitive.BOOLEAN).build();
public static final JsonSchemaType OBJECT = JsonSchemaType.builder(JsonSchemaPrimitive.OBJECT).build();
public static final JsonSchemaType ARRAY_WITH_STRING_ITEMS = JsonSchemaType.builder(JsonSchemaPrimitive.ARRAY).withItems(STRING_TYPE).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have a constant for an array that contains items of a certain type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because previously we just have Array without items and it was the reason of failing during refresh schema. Currently throwing exception in such case was changed to logging error message and we are adding items to array on source side.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry. This really doesn't make sense to me. It seems like for Postgres that we are making the assumption that all arrays will be string arrays. That is not how postgres works. The docs say other types are supported. This is just going to break.

@grishick

@sashaNeshcheret sashaNeshcheret temporarily deployed to more-secrets August 2, 2022 10:27 Inactive
@sashaNeshcheret
Copy link
Contributor Author

sashaNeshcheret commented Aug 2, 2022

/test connector=connectors/source-postgres

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

Build Passed

Test summary info:

All Passed

Copy link
Contributor

@ryankfu ryankfu left a comment

Choose a reason for hiding this comment

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

Unless my context is incorrect, the issue is that for JsonSchemaType.ARRAY there should be a corresponding field items that indicates the type of information in the array: https://cswr.github.io/JsonSchema/spec/arrays/

What this solution seems to implement is a limited scope of only having the items be only of type strings which as Charles has mentioned is not the only datatype that postgres arrays can support. Feel free to correct me if the understanding isn't clear but having the context included in the PR body would be helpful for everyone to get up to speed

Furthermore, since this is a change in the current behavior it would seem that a good practice is to add a regression test that covers the scenario where items field is not defined for array datatypes and also tests that validates the various datatypes that postgres arrays supports. How can we help make sure you're unblocked on this issue?

@sashaNeshcheret
Copy link
Contributor Author

sashaNeshcheret commented Aug 3, 2022

@ryankfu, @cgardens you are right, solution that implemented in this PR was just for handling on-call issue and has limitation about types of items as possible quick solution. As far as on-call issue was fixed by PR and this approach has concerns, we can finish with temporal solution and discuss long term approach.
We investigated issue internally with team and for first point of view we have two several solution.
First solution is revert PR and leave as is, so we will use just JsonSchemaType.ARRAY without items and their types.
Another way is extend JDBCType(that just have java.sql.ARRAY type) with new types ARRAY_INT, ARRAY_TEXT etc, but seems we can just do it with copy paste JDBCType. With created PostgresJDBCType we can specify correct data type for array items. Something similar we have for MySqlSourceOperations that does not extend JdbcSourceOperations as all jdbc related sources, but implements SourceOperations with own MysqlType, but it require a lot of refactoring and testing.
@grishick @edgao @tuliren

CC: @alexandr-shegeda @VitaliiMaltsev

@cgardens
Copy link
Contributor

closing as stale. feel free to re-open if this is something we are still working on.

@cgardens cgardens closed this Oct 31, 2022
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/platform issues related to the platform area/protocol connectors/source/postgres
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants