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 Salesforce Connector #3747

Merged
merged 13 commits into from
Jan 15, 2024
Merged

Add Salesforce Connector #3747

merged 13 commits into from
Jan 15, 2024

Conversation

cwarden
Copy link
Contributor

@cwarden cwarden commented Dec 22, 2023

Checklist

  • Manual verification
  • Unit test coverage
  • E2E test coverage
  • Needs manual QA?

Summary

Issue addressed:

Use Salesforce Bulk API as a source.

Details:

Add Salesforce connector supporting the FileIterator interface using the Bulk API with CSV jobs.

Each source requires a SOQL Query and SObject name.

Credentials can be provided for the source or the connector.

Each bulk job batch is retrieved as a single CSV file for rill to ingest.

Steps to Verify

  1. Add a new Source
  2. Select Salesforce
  3. Enter Username, Password (with token), SOQL Query, and SObject Name

@k-anshul
Copy link
Member

Hey @cwarden

Thanks a lot for working on this.
We are both very happy and impressed to see such important contributions from community members.
I understand this is still a draft but thought to pass some high level feedback on this :
There seems to be some boiler plate code around authentication and the bulk API call and I wonder if some library already achieves the same. We already use libraries for s3/gcs/bigquery/snowflake etc to do something similar.
I took a quick look and found this library but need to evaluate if it supports the features we need to build a MVP connector here. Please let me know what are your thoughts on this and any other library suggestions you might have.

Thank you and looking forward to contribute on this with you.

@cwarden
Copy link
Contributor Author

cwarden commented Dec 27, 2023

Thanks a lot for working on this. We are both very happy and impressed to see such important contributions from community members. I understand this is still a draft but thought to pass some high level feedback on this : There seems to be some boiler plate code around authentication and the bulk API call and I wonder if some library already achieves the same. We already use libraries for s3/gcs/bigquery/snowflake etc to do something similar. I took a quick look and found this library but need to evaluate if it supports the features we need to build a MVP connector here. Please let me know what are your thoughts on this and any other library suggestions you might have.

I'm using the force cli library, which I maintain. It's grown out of the command-line tool and some of the code dates back to Go 1.1 so there are some rough edges, but it has been heavily used.

I plan to clean up the authentication in this PR so it doesn't use a credential store.

I'm not sure if it makes sense to move some of the Bulk API handling into the library, but I'm open to suggestions.

Add Salesforce connector supporting the FileIterator interface using the
Bulk API with CSV jobs.

Each source requires a SOQL Query and SObject name.

Credentials can be provided for the source or the connector.
Username/password and JWT authentication is supported.

Each bulk job batch result is retrieved as a single CSV file for rill to
ingest.
@cwarden cwarden marked this pull request as ready for review December 27, 2023 18:43
runtime/drivers/salesforce/sql_store.go Show resolved Hide resolved
runtime/drivers/salesforce/sql_store.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/bulk.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/bulk.go Show resolved Hide resolved
Update error strings to be lowercase for consistency with existing
convention.
Update salesforce.authenticate method to return an error if there is no
Connected App client id defined.
Remove Authenticable interface and forceProvider implementation.  For
force functions directly.
JwtAssertionForEndpoint takes a file containing the signing key for
creating a JWT assertion.  Write the configured key to a temp file.
Use force.Force directly.
@cwarden
Copy link
Contributor Author

cwarden commented Jan 10, 2024

Thanks for the thorough code review, @k-anshul. You're seeing some of the artifacts of this code being extracted from an existing application, such as the interfaces that were used to facilitate testing.

runtime/drivers/salesforce/authentication.go Outdated Show resolved Hide resolved
runtime/drivers/salesforce/bulk.go Show resolved Hide resolved
Short-circuit and return default endpoint if no endpoint is defined.

Make code clearer when scheme is missing from the endpoint.
Copy link
Member

@k-anshul k-anshul left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @cwarden LGTM
I will also let @begelundmuller take a look at this.
Two things:

  1. I discovered that whenever I am submitting an incorrect query, the application gets stuck. Could you please take a look at this ? Sample incorrect query : SELECT Id, IsDeleted, Name, Type, ParentId, Rating, Site FROM Account WHERE Rating is not null
  2. Would you also be interested in adding docs for the connector ? It can also be taken up in a separate PR. PR for reference : https://github.com/rilldata/rill/pull/3147/files

If the query is invalid and the initial PK chunking batch fails, return
an error.
@cwarden
Copy link
Contributor Author

cwarden commented Jan 15, 2024

Thanks for the PR @cwarden LGTM I will also let @begelundmuller take a look at this. Two things:

  1. I discovered that whenever I am submitting an incorrect query, the application gets stuck. Could you please take a look at this ? Sample incorrect query : SELECT Id, IsDeleted, Name, Type, ParentId, Rating, Site FROM Account WHERE Rating is not null

Fixed in d82fb1f.

  1. Would you also be interested in adding docs for the connector ? It can also be taken up in a separate PR. PR for reference : https://github.com/rilldata/rill/pull/3147/files

Added in 8951aec.

Copy link
Member

@k-anshul k-anshul left a comment

Choose a reason for hiding this comment

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

Thanks

@k-anshul k-anshul merged commit 2a71b2b into rilldata:main Jan 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants