From 5e2dd80d84c6aa80358607ea90406dc90095874b Mon Sep 17 00:00:00 2001 From: Robert Schmidtke Date: Tue, 20 Jun 2023 13:59:02 +0200 Subject: [PATCH 1/4] expression filtering is no longer experimental --- moto/glue/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/moto/glue/utils.py b/moto/glue/utils.py index 11b063692..33e67796a 100644 --- a/moto/glue/utils.py +++ b/moto/glue/utils.py @@ -1,7 +1,6 @@ import abc import operator import re -import warnings from datetime import date, datetime from itertools import repeat from typing import Any, Dict, List, Optional, Union @@ -352,7 +351,6 @@ class PartitionFilter: if expression is None: return True - warnings.warn("Expression filtering is experimental") versions = list(self.fake_table.versions.values()) return expression.eval( part_keys=versions[-1].get("PartitionKeys", []), From 114d3807d77599960cf4365a24e94488d26859cc Mon Sep 17 00:00:00 2001 From: Robert Schmidtke Date: Tue, 20 Jun 2023 14:00:28 +0200 Subject: [PATCH 2/4] DelimitedList is new in pyparsing 3.1.0 and will deprecate delimited_list in a future release --- moto/glue/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/moto/glue/utils.py b/moto/glue/utils.py index 33e67796a..326187912 100644 --- a/moto/glue/utils.py +++ b/moto/glue/utils.py @@ -15,13 +15,19 @@ from pyparsing import ( Suppress, Word, alphanums, - delimited_list, exceptions, infix_notation, one_of, pyparsing_common, ) +try: + # TODO import directly when depending on pyparsing>=3.1.0 + from pyparsing import DelimitedList +except ImportError: + # delimited_list is deprecated in favor of DelimitedList in pyparsing 3.1.0 + from pyparsing import delimited_list as DelimitedList + from .exceptions import ( InvalidInputException, InvalidStateException, @@ -279,7 +285,7 @@ class _PartitionFilterExpressionCache: string <<= QuotedString(quote_char="'", esc_quote="''") | lpar + string + rpar # type: ignore literal = (number | string).set_name("literal") - literal_list = delimited_list(literal, min=1).set_name("list") + literal_list = DelimitedList(literal, min=1).set_name("list") bin_op = one_of("<> >= <= > < =").set_name("binary op") From fb7c32bc0e654c48737a26c613d2c69133bcbdd7 Mon Sep 17 00:00:00 2001 From: Robert Schmidtke Date: Tue, 20 Jun 2023 14:58:11 +0200 Subject: [PATCH 3/4] ignore type error as delimited_list is a function, but DelimitedList is a class --- moto/glue/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/glue/utils.py b/moto/glue/utils.py index 326187912..04cacbd85 100644 --- a/moto/glue/utils.py +++ b/moto/glue/utils.py @@ -26,7 +26,7 @@ try: from pyparsing import DelimitedList except ImportError: # delimited_list is deprecated in favor of DelimitedList in pyparsing 3.1.0 - from pyparsing import delimited_list as DelimitedList + from pyparsing import delimited_list as DelimitedList # type: ignore[assignment] from .exceptions import ( InvalidInputException, From 2ea551b6a3265a4927f4b91009680756e7c9ce3e Mon Sep 17 00:00:00 2001 From: Robert Schmidtke Date: Tue, 20 Jun 2023 17:07:30 +0200 Subject: [PATCH 4/4] fix test, as filtering no longer emits experimental warning --- tests/test_glue/test_partition_filter.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_glue/test_partition_filter.py b/tests/test_glue/test_partition_filter.py index 4bfa6aa1b..12bf31fcd 100644 --- a/tests/test_glue/test_partition_filter.py +++ b/tests/test_glue/test_partition_filter.py @@ -346,12 +346,11 @@ def test_get_partition_expression_warnings_and_exceptions(): kwargs = {"DatabaseName": database_name, "TableName": table_name} - with pytest.warns(match="Expression filtering is experimental"): - response = client.get_partitions(**kwargs, Expression="string_col = 'test'") - partitions = response["Partitions"] - partitions.should.have.length_of(1) - partition = partitions[0] - partition["Values"].should.equal(["test", "int", "3.14"]) + response = client.get_partitions(**kwargs, Expression="string_col = 'test'") + partitions = response["Partitions"] + partitions.should.have.length_of(1) + partition = partitions[0] + partition["Values"].should.equal(["test", "int", "3.14"]) with pytest.raises(ClientError) as exc: client.get_partitions(**kwargs, Expression="float_col = 3.14")