test(sql): cover mysql/snowflake in SHOW-statement FORCE_LIMIT regression test

Parametrize the regression test over engines whose sqlglot dialect
parses SHOW into a real exp.Show node (starrocks, mysql, snowflake),
not just starrocks, since the fix guards on AST node type rather than
dialect and any of these engines is equally exposed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rusackas
2026-07-29 18:29:14 -07:00
parent c62b9d6812
commit 3265f42418

View File

@@ -2243,6 +2243,17 @@ def test_set_limit_value(
assert statement.format() == expected
@pytest.mark.parametrize(
"engine",
[
# Engines whose sqlglot dialect parses `SHOW` into a real `exp.Show`
# node (as opposed to falling back to an opaque `exp.Command`, which
# doesn't expose a `limit` arg and so was never affected by this bug).
"starrocks",
"mysql",
"snowflake",
],
)
@pytest.mark.parametrize(
"sql",
[
@@ -2251,7 +2262,9 @@ def test_set_limit_value(
"SHOW CREATE TABLE test.will_test1",
],
)
def test_set_limit_value_leaves_show_statements_unchanged(sql: str) -> None:
def test_set_limit_value_leaves_show_statements_unchanged(
sql: str, engine: str
) -> None:
"""
Regression for #36939: FORCE_LIMIT must not touch ``SHOW`` statements.
@@ -2263,8 +2276,13 @@ def test_set_limit_value_leaves_show_statements_unchanged(sql: str) -> None:
syntax error ... Unexpected input 'LIMIT'". The statement should be
left untouched instead, matching how ``SELECT`` statements without a
scannable row source aren't force-limited either.
Covers multiple engines, not just StarRocks: the fix guards on the AST
node type (``exp.Show``), not the dialect, so any engine whose sqlglot
dialect parses ``SHOW`` into a real ``Show`` node (e.g. MySQL, Snowflake)
is equally exposed and must be equally protected.
"""
statement = SQLStatement(sql, "starrocks")
statement = SQLStatement(sql, engine)
original = statement.format()
statement.set_limit_value(1000, LimitMethod.FORCE_LIMIT)
assert statement.format() == original