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:
commit
b11cc6a5fe
@ -1,7 +1,6 @@
|
|||||||
import abc
|
import abc
|
||||||
import operator
|
import operator
|
||||||
import re
|
import re
|
||||||
import warnings
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
@ -16,13 +15,19 @@ from pyparsing import (
|
|||||||
Suppress,
|
Suppress,
|
||||||
Word,
|
Word,
|
||||||
alphanums,
|
alphanums,
|
||||||
delimited_list,
|
|
||||||
exceptions,
|
exceptions,
|
||||||
infix_notation,
|
infix_notation,
|
||||||
one_of,
|
one_of,
|
||||||
pyparsing_common,
|
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 (
|
from .exceptions import (
|
||||||
InvalidInputException,
|
InvalidInputException,
|
||||||
InvalidStateException,
|
InvalidStateException,
|
||||||
@ -280,7 +285,7 @@ class _PartitionFilterExpressionCache:
|
|||||||
string <<= QuotedString(quote_char="'", esc_quote="''") | lpar + string + rpar # type: ignore
|
string <<= QuotedString(quote_char="'", esc_quote="''") | lpar + string + rpar # type: ignore
|
||||||
|
|
||||||
literal = (number | string).set_name("literal")
|
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")
|
bin_op = one_of("<> >= <= > < =").set_name("binary op")
|
||||||
|
|
||||||
@ -352,7 +357,6 @@ class PartitionFilter:
|
|||||||
if expression is None:
|
if expression is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
warnings.warn("Expression filtering is experimental")
|
|
||||||
versions = list(self.fake_table.versions.values())
|
versions = list(self.fake_table.versions.values())
|
||||||
return expression.eval(
|
return expression.eval(
|
||||||
part_keys=versions[-1].get("PartitionKeys", []),
|
part_keys=versions[-1].get("PartitionKeys", []),
|
||||||
|
@ -346,12 +346,11 @@ def test_get_partition_expression_warnings_and_exceptions():
|
|||||||
|
|
||||||
kwargs = {"DatabaseName": database_name, "TableName": table_name}
|
kwargs = {"DatabaseName": database_name, "TableName": table_name}
|
||||||
|
|
||||||
with pytest.warns(match="Expression filtering is experimental"):
|
response = client.get_partitions(**kwargs, Expression="string_col = 'test'")
|
||||||
response = client.get_partitions(**kwargs, Expression="string_col = 'test'")
|
partitions = response["Partitions"]
|
||||||
partitions = response["Partitions"]
|
partitions.should.have.length_of(1)
|
||||||
partitions.should.have.length_of(1)
|
partition = partitions[0]
|
||||||
partition = partitions[0]
|
partition["Values"].should.equal(["test", "int", "3.14"])
|
||||||
partition["Values"].should.equal(["test", "int", "3.14"])
|
|
||||||
|
|
||||||
with pytest.raises(ClientError) as exc:
|
with pytest.raises(ClientError) as exc:
|
||||||
client.get_partitions(**kwargs, Expression="float_col = 3.14")
|
client.get_partitions(**kwargs, Expression="float_col = 3.14")
|
||||||
|
Loading…
Reference in New Issue
Block a user