Skip to content

Commit a018273

Browse files
remove SEA tests in parameterized queries
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 563da71 commit a018273

File tree

1 file changed

+16
-110
lines changed

1 file changed

+16
-110
lines changed

tests/e2e/test_parameterized_queries.py

Lines changed: 16 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -405,20 +405,9 @@ def test_use_inline_off_by_default_with_warning(self, use_inline_params, caplog)
405405
"Consider using native parameters." not in caplog.text
406406
), "Log message should not be supressed"
407407

408-
@pytest.mark.parametrize(
409-
"extra_params",
410-
[
411-
{},
412-
{
413-
"use_sea": True,
414-
"use_cloud_fetch": False,
415-
"enable_query_result_lz4_compression": False,
416-
},
417-
],
418-
)
419-
def test_positional_native_params_with_defaults(self, extra_params):
408+
def test_positional_native_params_with_defaults(self):
420409
query = "SELECT ? col"
421-
with self.cursor(extra_params) as cursor:
410+
with self.cursor() as cursor:
422411
result = cursor.execute(query, parameters=[1]).fetchone()
423412

424413
assert result.col == 1
@@ -434,42 +423,19 @@ def test_positional_native_params_with_defaults(self, extra_params):
434423
["foo", "bar", "baz"],
435424
),
436425
)
437-
@pytest.mark.parametrize(
438-
"extra_params",
439-
[
440-
{},
441-
{
442-
"use_sea": True,
443-
"use_cloud_fetch": False,
444-
"enable_query_result_lz4_compression": False,
445-
},
446-
],
447-
)
448-
def test_positional_native_multiple(self, params, extra_params):
426+
def test_positional_native_multiple(self, params):
449427
query = "SELECT ? `foo`, ? `bar`, ? `baz`"
450428

451-
combined_params = {"use_inline_params": False, **extra_params}
452-
with self.cursor(extra_params=combined_params) as cursor:
429+
with self.cursor(extra_params={"use_inline_params": False}) as cursor:
453430
result = cursor.execute(query, params).fetchone()
454431

455432
expected = [i.value if isinstance(i, DbsqlParameterBase) else i for i in params]
456433
outcome = [result.foo, result.bar, result.baz]
457434

458435
assert set(outcome) == set(expected)
459436

460-
@pytest.mark.parametrize(
461-
"extra_params",
462-
[
463-
{},
464-
{
465-
"use_sea": True,
466-
"use_cloud_fetch": False,
467-
"enable_query_result_lz4_compression": False,
468-
},
469-
],
470-
)
471-
def test_readme_example(self, extra_params):
472-
with self.cursor(extra_params) as cursor:
437+
def test_readme_example(self):
438+
with self.cursor() as cursor:
473439
result = cursor.execute(
474440
"SELECT :param `p`, * FROM RANGE(10)", {"param": "foo"}
475441
).fetchall()
@@ -533,42 +499,19 @@ def test_native_recursive_complex_type(
533499
class TestInlineParameterSyntax(PySQLPytestTestCase):
534500
"""The inline parameter approach uses pyformat markers"""
535501

536-
@pytest.mark.parametrize(
537-
"extra_params",
538-
[
539-
{},
540-
{
541-
"use_sea": True,
542-
"use_cloud_fetch": False,
543-
"enable_query_result_lz4_compression": False,
544-
},
545-
],
546-
)
547-
def test_params_as_dict(self, extra_params):
502+
def test_params_as_dict(self):
548503
query = "SELECT %(foo)s foo, %(bar)s bar, %(baz)s baz"
549504
params = {"foo": 1, "bar": 2, "baz": 3}
550505

551-
combined_params = {"use_inline_params": True, **extra_params}
552-
with self.connection(extra_params=combined_params) as conn:
506+
with self.connection(extra_params={"use_inline_params": True}) as conn:
553507
with conn.cursor() as cursor:
554508
result = cursor.execute(query, parameters=params).fetchone()
555509

556510
assert result.foo == 1
557511
assert result.bar == 2
558512
assert result.baz == 3
559513

560-
@pytest.mark.parametrize(
561-
"extra_params",
562-
[
563-
{},
564-
{
565-
"use_sea": True,
566-
"use_cloud_fetch": False,
567-
"enable_query_result_lz4_compression": False,
568-
},
569-
],
570-
)
571-
def test_params_as_sequence(self, extra_params):
514+
def test_params_as_sequence(self):
572515
"""One side-effect of ParamEscaper using Python string interpolation to inline the values
573516
is that it can work with "ordinal" parameters, but only if a user writes parameter markers
574517
that are not defined with PEP-249. This test exists to prove that it works in the ideal case.
@@ -578,8 +521,7 @@ def test_params_as_sequence(self, extra_params):
578521
query = "SELECT %s foo, %s bar, %s baz"
579522
params = (1, 2, 3)
580523

581-
combined_params = {"use_inline_params": True, **extra_params}
582-
with self.connection(extra_params=combined_params) as conn:
524+
with self.connection(extra_params={"use_inline_params": True}) as conn:
583525
with conn.cursor() as cursor:
584526
result = cursor.execute(query, parameters=params).fetchone()
585527
assert result.foo == 1
@@ -599,18 +541,7 @@ def test_inline_ordinals_can_break_sql(self):
599541
):
600542
cursor.execute(query, parameters=params)
601543

602-
@pytest.mark.parametrize(
603-
"extra_params",
604-
[
605-
{},
606-
{
607-
"use_sea": True,
608-
"use_cloud_fetch": False,
609-
"enable_query_result_lz4_compression": False,
610-
},
611-
],
612-
)
613-
def test_inline_named_dont_break_sql(self, extra_params):
544+
def test_inline_named_dont_break_sql(self):
614545
"""With inline mode, ordinal parameters can break the SQL syntax
615546
because `%` symbols are used to wildcard match within LIKE statements. This test
616547
just proves that's the case.
@@ -620,30 +551,17 @@ def test_inline_named_dont_break_sql(self, extra_params):
620551
SELECT col_1 FROM base WHERE col_1 LIKE CONCAT(%(one)s, 'onite')
621552
"""
622553
params = {"one": "%(one)s"}
623-
combined_params = {"use_inline_params": True, **extra_params}
624-
with self.cursor(extra_params=combined_params) as cursor:
554+
with self.cursor(extra_params={"use_inline_params": True}) as cursor:
625555
result = cursor.execute(query, parameters=params).fetchone()
626556
print("hello")
627557

628-
@pytest.mark.parametrize(
629-
"extra_params",
630-
[
631-
{},
632-
{
633-
"use_sea": True,
634-
"use_cloud_fetch": False,
635-
"enable_query_result_lz4_compression": False,
636-
},
637-
],
638-
)
639-
def test_native_ordinals_dont_break_sql(self, extra_params):
558+
def test_native_ordinals_dont_break_sql(self):
640559
"""This test accompanies test_inline_ordinals_can_break_sql to prove that ordinal
641560
parameters work in native mode for the exact same query, if we use the right marker `?`
642561
"""
643562
query = "SELECT 'samsonite', ? WHERE 'samsonite' LIKE '%sonite'"
644563
params = ["luggage"]
645-
combined_params = {"use_inline_params": False, **extra_params}
646-
with self.cursor(extra_params=combined_params) as cursor:
564+
with self.cursor(extra_params={"use_inline_params": False}) as cursor:
647565
result = cursor.execute(query, parameters=params).fetchone()
648566

649567
assert result.samsonite == "samsonite"
@@ -659,25 +577,13 @@ def test_inline_like_wildcard_breaks(self):
659577
with pytest.raises(ValueError, match="unsupported format character"):
660578
result = cursor.execute(query, parameters=params).fetchone()
661579

662-
@pytest.mark.parametrize(
663-
"extra_params",
664-
[
665-
{},
666-
{
667-
"use_sea": True,
668-
"use_cloud_fetch": False,
669-
"enable_query_result_lz4_compression": False,
670-
},
671-
],
672-
)
673-
def test_native_like_wildcard_works(self, extra_params):
580+
def test_native_like_wildcard_works(self):
674581
"""This is a mirror of test_inline_like_wildcard_breaks that proves that LIKE
675582
wildcards work under the native approach.
676583
"""
677584
query = "SELECT 1 `col` WHERE 'foo' LIKE '%'"
678585
params = {"param": "bar"}
679-
combined_params = {"use_inline_params": False, **extra_params}
680-
with self.cursor(extra_params=combined_params) as cursor:
586+
with self.cursor(extra_params={"use_inline_params": False}) as cursor:
681587
result = cursor.execute(query, parameters=params).fetchone()
682588

683589
assert result.col == 1

0 commit comments

Comments
 (0)