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

🐛 fix(mongodb-v2): use max 10k documents while discovering MongoDB schema #8491

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

joelluijmes
Copy link
Contributor

@joelluijmes joelluijmes commented Dec 3, 2021

What

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

The mongodb v2 implementation doesn't limit the amount of documents while performing discovery. This PR remedies this behavior. The documentation of the MongoDB states the following:

Connector select 10k documents to collect all distinct field.
https://docs.airbyte.io/integrations/sources/mongodb-v2#step-1.-find-all-unique-properties

However, upon testing the integration I noticed it is taking way to long. Digging into the code I never found any references that it is limitted to 10k documents. As my source database has 1.2B documents, it makes sense why discovery taking so long 😓

Further looking around it was already mentioned on a previous PR.

the documentation probably originates from the v1 implementation, where there is an explicit limit.
https://github.com/airbytehq/airbyte/blob/5393070dc6c87c3fccad8b664cee8e30d3e52ba3/airbyte-integrations/connectors/source-mongodb/lib/mongodb_stream.rb

How

Describe the solution

This PR brings the integration in line with the behavior as described on the documentation. It does so by sampling 10k records at max. Note, the original approach used limit. I'd argue that sample is better approach for discovery.

Originally I implemented it with sample, as I thought it worked well. However, with sample of 10k documents, it is very slow. I reverted to the original limit implementation. Now it works :)

🚨 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/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
  • Credentials added to Github CI. 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
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory 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

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.

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2021

CLA assistant check
All committers have signed the CLA.

@joelluijmes joelluijmes force-pushed the fix/mongodb-v2-discovery branch from 148f917 to 290aaac Compare December 3, 2021 15:46
@joelluijmes joelluijmes changed the title 🐛 fix(mongodb-v2): use random 10k sample while discovering MongoDB schema 🐛 fix(mongodb-v2): use max 10k documents while discovering MongoDB schema Dec 3, 2021
@marcosmarxm
Copy link
Member

Thanks for the contribution @joelluijmes I requested the team to take a look and review it.

@marcosmarxm marcosmarxm added the gl label Dec 3, 2021
@ogirardot
Copy link

would love to see this integrated and ready to test it as I have the exact same issue

@github-actions github-actions bot added area/connectors Connector related issues area/documentation Improvements or additions to documentation area/frontend area/platform issues related to the platform area/scheduler area/server area/worker Related to worker CDK Connector Development Kit kubernetes labels Dec 7, 2021
@ogirardot
Copy link

\o/

@marcosmarxm marcosmarxm temporarily deployed to more-secrets December 7, 2021 19:16 Inactive
@marcosmarxm marcosmarxm force-pushed the fix/mongodb-v2-discovery branch from 1fa2e54 to 94a8a69 Compare December 7, 2021 19:18
@github-actions github-actions bot removed kubernetes area/worker Related to worker area/platform issues related to the platform area/server area/frontend area/scheduler CDK Connector Development Kit labels Dec 7, 2021
@marcosmarxm marcosmarxm merged commit ad55ab0 into airbytehq:master Dec 7, 2021
@joelluijmes joelluijmes deleted the fix/mongodb-v2-discovery branch December 8, 2021 07:29
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 community gl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants