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

[CT-1749] [Feature] Let Snowpark telemetry know that dbt is creating the sproc #374

Closed
3 tasks done
dataders opened this issue Jan 4, 2023 · 6 comments · Fixed by #383
Closed
3 tasks done

[CT-1749] [Feature] Let Snowpark telemetry know that dbt is creating the sproc #374

dataders opened this issue Jan 4, 2023 · 6 comments · Fixed by #383
Assignees
Labels
type:enhancement New feature or request

Comments

@dataders
Copy link
Contributor

dataders commented Jan 4, 2023

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt-snowflake functionality, rather than a Big Idea better suited to a discussion

Describe the feature

Snowflake is requesting that the below line of code be added to the body of user-created python functions used to create python UDFs on behalf of users behind the scenes and have PartnerName_ToolName="dbt"

sys._xoptions['snowflake_partner_attribution'].append("PartnerName_ToolName")

Below is where our template of sproc creation is implemented. It seems the implementation would be to somehow modify the function definition in compiled_code to also include the sys._xoptions call?

common_procedure_code = f"""
RETURNS STRING
LANGUAGE PYTHON
RUNTIME_VERSION = '{python_version}'
PACKAGES = ('{packages}')
{imports}
HANDLER = 'main'
EXECUTE AS CALLER
AS
$$
{compiled_code}
$$"""

This is an example provide by the Snowflake team

create function python_udf_usage_tracking(c1 int, c2 int)
returns double
language python
runtime_version='3.8'
handler = 'PartnerTrackingTest'
as $$$$
import sys
 
def sum(a,b):
    sum=a+b
    sys._xoptions['snowflake_partner_attribution'].append("PartnerName_ToolName")
    return sum
$$$$;

Describe alternatives you've considered

We do nothing

This is one idea

We add a session parameter to connection creation?

Not sure if this would be helpful for the Snowpark team, that wants to track consumption...

https://github.com/dbt-labs/dbt-snowflake/blob/main/dbt/adapters/snowflake/connections.py#L284-L285

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response

@dataders dataders added type:enhancement New feature or request triage:product labels Jan 4, 2023
@github-actions github-actions bot changed the title [Feature] Let Snowpark telemetry know that dbt is creating the sproc [CT-1749] [Feature] Let Snowpark telemetry know that dbt is creating the sproc Jan 4, 2023
@ChenyuLInx
Copy link
Contributor

Do we have to call sys._xoptions inside user's function? can we just do it at the very end or very beginning right after import sys?

@lostmygithubaccount
Copy link

agreed we should move it if possible to below the import instead of in user code

I don't see any reason we couldn't/shouldn't do this, would definitely check w/ @jtcohen6 to be sure

@sfc-gh-ripu
Copy link

@dataders can you please expand on the alternate solution linked? Are you suggesting dbt python models will be able to add a specific query tag, say "snowpark_python" ?

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jan 5, 2023

@sfc-gh-ripu If I understand right, we're awaiting confirmation from folks on your side that it's possible to do something similar to sys._xoptions['snowflake_partner_attribution'] (which works in UDFs) in stored procedures as well, since that's how we're currently creating + calling dbt Python models on Snowpark.

@dataders My hesitation with the query_tag approach is, that's something we've opened up fully to user-space configuration. Users can add/remove whatever query_tag they want, and it's fully visible within their own query histories. Whereas application or snowflake_partner_attribution are just for use by Snowflake + partners.

@sfc-gh-ripu
Copy link

@dataders I confirmed with Snowpark team, the sys._xoptions['snowflake_partner_attribution'].append("PartnerName_ToolName")
statement can be outside user function, and will work directly from the body of a sproc as well, right after import sys statement.

@dataders
Copy link
Contributor Author

dataders commented Jan 9, 2023

@sfc-gh-ripu amazing! just opened up #383 as a draft. @ChenyuLInx @colin-rogers-dbt wanna take a look?

@jtcohen6 jtcohen6 removed their assignment Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants