snowflakedb / snowflake-cli

Snowflake CLI is an open-source command-line tool explicitly designed for developer-centric workloads in addition to SQL operations.

Home Page:https://docs.snowflake.com/developer-guide/snowflake-cli-v2/index

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SNOW-1130627: SqlExecutionManager.to_fully_qualified_name converts name to upper case and may not split properly if a quoted identifier has a dot in it.

sfc-gh-davwang opened this issue · comments

SnowCLI version

2.1.0rc0

Python version

3.11.7

Platform

macOS-14.3-arm64-arm-64bit

What happened

(DID NOT ACTUALLY PRODUCE ERROR)

In SqlExecutionMixin, the to_fully_qualified_name function converts the entire name to uppercase. This is problematic because if you have two quoted identifiers with the same letters but different casing, they will be indistinguishable. Another issue is that the method splits the name into database, schema, name just by splitting on dot, but quoted identifiers for any of those could have a dot in them (e.g. "d.b".schema.name), which would result in improper parsing. Should probably be done through regex instead.

image

Console output

N/A

How to reproduce

You could likely get a bug to occur if you first deployed a stored procedure or function with a quoted identifier (e.g. "quoted identifier"(arg1 VARCHAR)) and then tried to deploy another stored procedure or function with a quoted identifier that has the same letters but different casing (e.g. "QUOTED identifier"(arg1 VARCHAR)). I believe it would say db.schema."QUOTED identifier"(...) already exists because it has the same name as "quoted identifier"(arg1 VARCHAR)) after being converted to upper case.

We're going to improve support for quoted identifiers but it won't a part of 2.1.0 release.