Skip to content

Conversation

@utkarsharma2
Copy link
Contributor

@utkarsharma2 utkarsharma2 commented Apr 18, 2023

Implemented Snowflake SQL API Operator to support multiple SQL statements, the Snowflake SQL API allows submitting multiple SQL statements in a single request, which currently is not possible with SnowflakeOperator as it submits multiple statements sequentially.

This Operator currently uses key pair authentication, so you need to provide private key raw content or private key file path in the snowflake connection along with other details.

Snowflake SQL API key pair - Authentication https://docs.snowflake.com/en/developer-guide/sql-api/authenticating.html#label-sql-api-authenticating-key-pair

Where can this operator fit in?
- To execute multiple SQL statements in a single request
- To execute the SQL statement and to execute standard queries and most DDL and DML statements

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues provider:snowflake Issues related to Snowflake provider labels Apr 18, 2023
@utkarsharma2 utkarsharma2 marked this pull request as draft April 18, 2023 04:33
@utkarsharma2 utkarsharma2 changed the title Add deferrable SnowflakeSqlApiOperatorAsyn operator Add deferrable SnowflakeSqlApiOperator operator Apr 27, 2023
@utkarsharma2 utkarsharma2 changed the title Add deferrable SnowflakeSqlApiOperator operator Add SnowflakeSqlApiOperator operator May 9, 2023
@utkarsharma2 utkarsharma2 reopened this May 9, 2023
@utkarsharma2 utkarsharma2 marked this pull request as ready for review May 10, 2023 04:15
Copy link
Contributor

@phanikumv phanikumv left a comment

Choose a reason for hiding this comment

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

Please add documentation and example DAG

@utkarsharma2
Copy link
Contributor Author

utkarsharma2 commented May 16, 2023

@phanikumv Added documents and example, please review.

@utkarsharma2
Copy link
Contributor Author

utkarsharma2 commented May 16, 2023

@potiuk please review

@utkarsharma2 utkarsharma2 requested a review from phanikumv May 16, 2023 06:42
@potiuk
Copy link
Member

potiuk commented May 16, 2023

@potiuk please review

I thinkj it's better to avoid calling specific people (unless we know they want to be called). I might be on holidays or focusing on something else. By calling me personally here (when I was not involved before especially) you are limiting the chances for things to be reviewed (because others might think I will do it). It's better to just ask for review in general - or ping people if they have been reviewing things before than asking people directly to do review..

Note to self - we need to upgrade our CODEOWNERS rules actually as they might be misleding and they are wrong in multiple cases.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

LGTM. Maybe @mik-laj -you would like to have a look ?

@utkarsharma2
Copy link
Contributor Author

@potiuk Sure, I'll keep that in mind going forward. Thanks for reviewing :)

@potiuk
Copy link
Member

potiuk commented May 16, 2023

If we don't hear from Snowflake team, we are going t merge it soon anyway @eladkal - might be worth merging before the next wave ? But maybe we can drag attention of the Snowflake team to do more review here (there was somoene at Snowflake who looked at the changes before I recall @mik-laj ?

@ephraimbuddy ephraimbuddy merged commit 739e6b5 into apache:main May 24, 2023
@@ -0,0 +1,174 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a hook.
it looks more like util and should be in util path

Copy link
Contributor Author

@utkarsharma2 utkarsharma2 May 25, 2023

Choose a reason for hiding this comment

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

Yes, that makes sense. I'll raise a separate PR to move it. thanks for pointing it out :)

python-modules:
- airflow.providers.snowflake.hooks.snowflake
- airflow.providers.snowflake.hooks.snowflake_sql_api
- airflow.providers.snowflake.hooks.sql_api_generate_jwt
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not right. it's not a hook.

self.query_ids: list[str] = []


class SnowflakeSqlApiOperator(SnowflakeOperator):
Copy link
Contributor

@eladkal eladkal May 31, 2023

Choose a reason for hiding this comment

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

This is not good.
SnowflakeOperator is deprecated. We should not extend it's functionality.

This class needs to be refactored around SQLExecuteQueryOperator, BaseOperator or possibly have a SnowflakeBaseOperator class ?

Copy link
Contributor

Choose a reason for hiding this comment

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

For reference... followup PR #31751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants