Skip to content

Commit 01c662e

Browse files
elipollakclaude
andauthored
test: add COPY INTO, LATERAL FLATTEN, and additional Snowflake dialect test coverage (#173)
Add tests for Snowflake-specific syntax not covered by #170: COPY INTO, LATERAL FLATTEN, nested dot-path notation, bracket notation, OBJECT_CONSTRUCT, and GET_PATH. Also add Copy to the README permissions example so users can configure it explicitly. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 991e54f commit 01c662e

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ sql_statement_permissions: # List SQL statements to explicitly allow (True) or d
7777
- Command: True
7878
- Comment: True
7979
- Commit: True
80+
- Copy: True
8081
- Create: True
8182
- Delete: True
8283
- Describe: True

mcp_server_snowflake/tests/test_query_manager_tools.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13+
import pytest
14+
1315
from mcp_server_snowflake.query_manager.tools import (
1416
get_statement_type,
1517
validate_sql_type,
@@ -53,6 +55,33 @@ def test_column_colon_path_with_cast(self):
5355
assert get_statement_type("SELECT v:city::string FROM t") == "Select"
5456

5557

58+
class TestSnowflakeSpecificSyntax:
59+
"""Additional Snowflake dialect coverage: COPY INTO, LATERAL FLATTEN, etc."""
60+
61+
@pytest.mark.parametrize(
62+
"sql",
63+
[
64+
"SELECT data:user.address.city::STRING FROM t",
65+
"SELECT data['key'] FROM t",
66+
"SELECT f.value:key::STRING FROM t, LATERAL FLATTEN(input => t.arr) f",
67+
"SELECT f.value::STRING FROM t, LATERAL FLATTEN(input => t.arr) f",
68+
"SELECT OBJECT_CONSTRUCT('key', 'value') AS obj",
69+
"SELECT GET_PATH(data, 'a.b') FROM t",
70+
],
71+
)
72+
def test_snowflake_syntax_parses_as_select(self, sql):
73+
assert get_statement_type(sql) == "Select"
74+
75+
def test_copy_into_parses_as_copy(self):
76+
"""COPY INTO should parse as Copy, not Unknown (see #161)."""
77+
assert (
78+
get_statement_type(
79+
"COPY INTO @stage/file.csv FROM (SELECT * FROM t) FILE_FORMAT = (TYPE = CSV)"
80+
)
81+
== "Copy"
82+
)
83+
84+
5685
class TestValidateSqlType:
5786
def test_select_allowed(self):
5887
allow = ["select"]

0 commit comments

Comments
 (0)