Merge pull request #6427 from robert-schmidtke/feature/upgrade-pyparsing

pyparsing 3.1.0 support, remove experimental warning on Glue partition filtering
This commit is contained in:
Mike Grima 2023-06-20 17:31:11 -04:00 committed by GitHub
commit b11cc6a5fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -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
@ -16,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 # type: ignore[assignment]
from .exceptions import (
InvalidInputException,
InvalidStateException,
@ -280,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")
@ -352,7 +357,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", []),

View File

@ -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")