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 and Destination Snowflake: Add jdbc_url_params support for optional JDBC parameters #9623

Conversation

noahkawasakigoogle
Copy link
Contributor

@noahkawasakigoogle noahkawasakigoogle commented Jan 20, 2022

What

Add support for Snowflakes Source and Destination's to take in a JDBC URL Params input to specify any additional JDBC parameters for the connection.

Solves Snowflake for #9501

Eventually I would like to have this for all connectors that support this: #9598

How

Add in jdbc_url_params for Snowflake in the config Jsonode. Optionally append to the JDBC string if exists.

Also, I'm unsure on how I am supposed to run the integration tests myself without the secrets, is it expected that I should create my own personal Snowflake account for this? Or is there an assumption that I am the original Snowflake connector developer and already have these credentials?

Recommended reading order

Very simple, any file

🚨 User Impact 🚨

Pre-merge Checklist

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

@github-actions github-actions bot added the area/connectors Connector related issues label Jan 20, 2022
@noahkawasakigoogle noahkawasakigoogle changed the title Source Snowflake: Add jdbc_url_params support 🎉 Source and Destination Snowflake: Add jdbc_url_params support for optional JDBC parameters Jan 20, 2022
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Jan 20, 2022
@noahkawasakigoogle
Copy link
Contributor Author

/test connector=source-snowflake
/test connector=destination-snowflake

@noahkawasakigoogle noahkawasakigoogle marked this pull request as ready for review January 20, 2022 21:51
@alafanechere alafanechere self-assigned this Jan 21, 2022
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

Hi @noahkawasakigoogle, thank you very much for this contrib!
I made minor suggestions, let me know what you think.
Could you also please bump the version of the connectors you edited:

  • In the Dockerfiles
  • In airbyte-config/init/src/main/resources/seed/source_definitions.yaml
  • In airbyte-config/init/src/main/resources/seed/destination_definitions.yaml
  • In airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/e2d65910-8c8b-40a1-ae7d-ee2416b2bfa2.json
  • In airbyte-config/init/src/main/resources/config/STANDARD_DESTINATION_DEFINITION/424892c4-daac-4491-b35d-c6688ba547ba.json

I'll run the integration test in our CI and send you the results.

@alafanechere alafanechere mentioned this pull request Jan 21, 2022
@alafanechere alafanechere temporarily deployed to more-secrets January 21, 2022 16:57 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 21, 2022 16:58 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 21, 2022 16:58 Inactive
@noahkawasakigoogle
Copy link
Contributor Author

noahkawasakigoogle commented Jan 21, 2022

Thanks for reviewing! For some reason I thought the rest of the docker tag bumps happened in some automatic workflow. Just made them. Also removed the LICENSE file in the docs directory. Will open a separate PR for that. I had some responses to the JDBC nits, lemme know what you think.

#9701

@alafanechere
Copy link
Contributor

I confirm acceptance tests pass for the source connector. I'll keep you updated about the destination as the run is longer.

Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

Acceptance tests passed for both connectors. @misteryeo / @sherifnada could you please give a final review as the spec.json was changed?

@noahkawasakigoogle
Copy link
Contributor Author

Can we make sure to approve and merge this before this PR if approved? As I am only supposed to contribute to non Elastic licensed files

Copy link

@pjleiwa6g pjleiwa6g left a comment

Choose a reason for hiding this comment

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

To make it possible to enter a value like query_tag={'TOOL':'AIRBYTE','CUSTID':'1001'} can url encoding be added too? Example is in the attached file.

SnowflakeDatabase.java.txt

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;

....
  if (config.has("jdbc_url_params")) {
        jdbcUrl.append(encodeValue(config.get("jdbc_url_params").asText()));
.... 

  private static String encodeValue(String value) {
        try {
            return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()).replace("%3D","=").replace("%26","&");
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex.getCause());
        }
  }

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

Hey @noahkawasakigoogle ! Thanks for creating the PR. It's actually my first time seeing the epic linked to this PR, so I asked a bunch of questions on the main issue here: #9501 apologies for being a little behind you on this. Feel free to chime in on those questions as well

@misteryeo do you have thoughts on the UX questions in that issue?

@noahkawasakigoogle
Copy link
Contributor Author

@sherifnada No prob! I replied with some thoughts.

@pjleiwa6g Hm, yeah this could happen. Do you think it would be possible to just put the URL encoded characters directly in the connection though? Snowflake documents this example:

String connectionURL = "jdbc:snowflake://myorganization-myaccount.snowflakecomputing.com/?query_tag='folder%3Dfolder1%20folder2%26'

My concern is just that Airbyte doing string manipulation behind the scenes makes it more vague whats going on to end users, and that there could be more and more characters to add search and replace logic for. This approach is more transparent: "What you put in will get sent to Snowflake". I'm open to either choice though. Also to answer your question on the other ticket, QUERY_TAG works here, tested that one specifically. Any of the Snowflake parameters can also be set this way.

@pjleiwa6g
Copy link

@noahkawasakigoogle I'm think you are right that it makes it more vague for end users. I tested it by entering an encoded string and it works fine. You can forget my comment.

Copy link
Contributor

@misteryeo misteryeo left a comment

Choose a reason for hiding this comment

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

Just added one comment but otherwise LGTM!

@misteryeo
Copy link
Contributor

misteryeo commented Jan 27, 2022 via email

@alafanechere alafanechere temporarily deployed to more-secrets January 27, 2022 08:31 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 27, 2022 08:32 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 27, 2022 08:32 Inactive
@noahkawasakigoogle
Copy link
Contributor Author

I see this in CI:

airbyte/destination-snowflake: 0.4.5
	URL: https://hub.docker.com/v2/repositories/airbyte/destination-snowflake/tags/0.4.5
curl: (22) The requested URL returned error: 404 Not Found
	ERROR: not found!

I'm assuming this is expected from my fork since this hasnt merged?

@alafanechere
Copy link
Contributor

I see this in CI:

airbyte/destination-snowflake: 0.4.5
	URL: https://hub.docker.com/v2/repositories/airbyte/destination-snowflake/tags/0.4.5
curl: (22) The requested URL returned error: 404 Not Found
	ERROR: not found!

I'm assuming this is expected from my fork since this hasnt merged?

Yes exactly, I was running final tests after your latest commit on a side branch. They are passing, so I'm going to publish the connectors now.

@alafanechere alafanechere temporarily deployed to more-secrets January 28, 2022 16:10 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets January 28, 2022 16:11 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets January 28, 2022 18:37 Inactive
@alafanechere alafanechere merged commit 5391880 into airbytehq:master Jan 28, 2022
@alafanechere
Copy link
Contributor

Thank you @noahkawasakigoogle for this contribution! I re-bumped the version myself because of some conflicts with the destination connectors.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants