snowflakedb / snowflake-cli

Snowflake CLI is an open-source command-line tool explicitly designed for developer-centric workloads in addition to SQL operations.
https://docs.snowflake.com/developer-guide/snowflake-cli-v2/index
Apache License 2.0
178 stars 55 forks source link

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

Open lorcan17 opened 1 week ago

lorcan17 commented 1 week ago

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:

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

lorcan17 commented 6 days ago

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:

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 )