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

SNOW-1711304: snow snowpark deploy wraps null in quotes if type is string or varchar #1668

Open
lorcan17 opened this issue Oct 4, 2024 · 1 comment

Comments

@lorcan17
Copy link

lorcan17 commented Oct 4, 2024

SnowCLI version

2.8.1

Python version

3.10.13

Platform

Windows-10-10.0.22631-SP0

What happened

My snowflake.yml file is set with the below configurations:
definition_version: "1.1" snowpark: project_name: "examlpe" stage_name: "examlpe" src: "example/" procedures: - name: example database: meta_db schema: config handler: "example.example" signature: - name: streams type: variant default: null - name: views type: variant default: null - name: cron_expr type: string default: null - name: timezone_str type: varchar default: America/Los_Angeles - name: daily_max_refresh type: number default: null returns: varchar

When I run snowpark deploy the output shows that the string default value for cron_expr is incorrectly stated as 'null' instead of null

Console output

2024-10-03 16:52:49 DEBUG [snowflake.cli.api.sql_execution] Executing create or replace procedure IDENTIFIER('example.example.example')(streams variant default null, views variant default null, timezone_str varchar default 'America/Los_Angeles', cron_expr string default 'null', daily_max_refresh number default null)`

How to reproduce

As above

@github-actions github-actions bot changed the title snow snowpark deploy wraps null in quotes if type is string.varchar SNOW-1711304: snow snowpark deploy wraps null in quotes if type is string.varchar Oct 4, 2024
@lorcan17 lorcan17 changed the title SNOW-1711304: snow snowpark deploy wraps null in quotes if type is string.varchar SNOW-1711304: snow snowpark deploy wraps null in quotes if type is string or varchar Oct 4, 2024
@lorcan17
Copy link
Author

lorcan17 commented Oct 4, 2024

How should default null values be specified in the snowflake.yml project definition file for type Variant and String so they are treated correctly by Python as None?

I have the following settings
signature: - name: workspace_id type: string - name: dataset_id type: string - name: refresh_body type: variant default: null - name: streams type: variant default: null - name: views type: variant default: null - name: cron_expr type: string default: null - name: timezone_str type: string default: America/Los_Angeles - name: daily_max_refresh type: number default: null returns: varchar

This generates the following logic in the store procedure:

CREATE OR REPLACE PROCEDURE "REFRESH_DATASET"( "WORKSPACE_ID" VARCHAR(16777216), "DATASET_ID" VARCHAR(16777216), "REFRESH_BODY" VARIANT DEFAULT NULL, "STREAMS" VARIANT DEFAULT NULL, "VIEWS" VARIANT DEFAULT NULL, "CRON_EXPR" VARCHAR(16777216) DEFAULT 'null', "TIMEZONE_STR" VARCHAR(16777216) DEFAULT 'America/Los_Angeles', "DAILY_MAX_REFRESH" NUMBER(38, 0) DEFAULT NULL ) RETURNS VARCHAR(16777216)

Where I want something like this as python interprets json nulls as None:
CREATE OR REPLACE PROCEDURE meta_db.config.refresh_dataset( "WORKSPACE_ID" VARCHAR(16777216), "DATASET_ID" VARCHAR(16777216), "REFRESH_BODY" VARIANT DEFAULT PARSE_JSON('null'), "STREAMS" VARIANT DEFAULT PARSE_JSON('null'), "VIEWS" VARIANT DEFAULT PARSE_JSON('null'), "CRON_EXPR" VARCHAR(16777216) DEFAULT NULL, "TIMEZONE_STR" VARCHAR(16777216) DEFAULT 'America/Los_Angeles', "DAILY_MAX_REFRESH" NUMBER(38, 0) DEFAULT NULL )

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

No branches or pull requests

1 participant