Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ sql_statement_permissions: # List SQL statements to explicitly allow (True) or d
- Command: True
- Comment: True
- Commit: True
- Copy: True
- Create: True
- Delete: True
- Describe: True
Expand Down
29 changes: 29 additions & 0 deletions mcp_server_snowflake/tests/test_query_manager_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from mcp_server_snowflake.query_manager.tools import (
get_statement_type,
validate_sql_type,
Expand Down Expand Up @@ -53,6 +55,33 @@ def test_column_colon_path_with_cast(self):
assert get_statement_type("SELECT v:city::string FROM t") == "Select"


class TestSnowflakeSpecificSyntax:
"""Additional Snowflake dialect coverage: COPY INTO, LATERAL FLATTEN, etc."""

@pytest.mark.parametrize(
"sql",
[
"SELECT data:user.address.city::STRING FROM t",
"SELECT data['key'] FROM t",
"SELECT f.value:key::STRING FROM t, LATERAL FLATTEN(input => t.arr) f",
"SELECT f.value::STRING FROM t, LATERAL FLATTEN(input => t.arr) f",
"SELECT OBJECT_CONSTRUCT('key', 'value') AS obj",
"SELECT GET_PATH(data, 'a.b') FROM t",
],
)
def test_snowflake_syntax_parses_as_select(self, sql):
assert get_statement_type(sql) == "Select"

def test_copy_into_parses_as_copy(self):
"""COPY INTO should parse as Copy, not Unknown (see #161)."""
assert (
get_statement_type(
"COPY INTO @stage/file.csv FROM (SELECT * FROM t) FILE_FORMAT = (TYPE = CSV)"
)
== "Copy"
)


class TestValidateSqlType:
def test_select_allowed(self):
allow = ["select"]
Expand Down
Loading