Skip to content

Commit 5ab5890

Browse files
authored
Merge branch 'main' into main
2 parents 95e5af2 + 8adf246 commit 5ab5890

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

poetry.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyiceberg/expressions/parser.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
DelimitedList,
2323
Group,
2424
MatchFirst,
25+
ParseException,
2526
ParserElement,
2627
ParseResults,
28+
QuotedString,
2729
Suppress,
2830
Word,
2931
alphanums,
@@ -79,7 +81,16 @@
7981
LIKE = CaselessKeyword("like")
8082

8183
unquoted_identifier = Word(alphas + "_", alphanums + "_$")
82-
quoted_identifier = Suppress('"') + unquoted_identifier + Suppress('"')
84+
quoted_identifier = QuotedString('"', escChar="\\", unquoteResults=True)
85+
86+
87+
@quoted_identifier.set_parse_action
88+
def validate_quoted_identifier(result: ParseResults) -> str:
89+
if "." in result[0]:
90+
raise ParseException("Expected '\"', found '.'")
91+
return result[0]
92+
93+
8394
identifier = MatchFirst([unquoted_identifier, quoted_identifier]).set_results_name("identifier")
8495
column = DelimitedList(identifier, delim=".", combine=False).set_results_name("column")
8596

pyiceberg/table/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ def update_snapshot(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> U
439439
"""
440440
return UpdateSnapshot(self, io=self._table.io, snapshot_properties=snapshot_properties)
441441

442+
def update_statistics(self) -> UpdateStatistics:
443+
"""
444+
Create a new UpdateStatistics to update the statistics of the table.
445+
446+
Returns:
447+
A new UpdateStatistics
448+
"""
449+
return UpdateStatistics(transaction=self)
450+
442451
def append(self, df: pa.Table, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> None:
443452
"""
444453
Shorthand API for appending a PyArrow table to a table transaction.

pyiceberg/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ class BucketTransform(Transform[S, int]):
234234
_num_buckets: PositiveInt = PrivateAttr()
235235

236236
def __init__(self, num_buckets: int, **data: Any) -> None:
237-
self._num_buckets = num_buckets
238237
super().__init__(f"bucket[{num_buckets}]", **data)
238+
self._num_buckets = num_buckets
239239

240240
@property
241241
def num_buckets(self) -> int:

tests/expressions/test_parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ def test_quoted_column_with_dots() -> None:
230230
with pytest.raises(ParseException) as exc_info:
231231
parser.parse("\"foo.bar\".baz = 'data'")
232232

233-
assert "Expected '\"', found '.'" in str(exc_info.value)
234-
235233
with pytest.raises(ParseException) as exc_info:
236234
parser.parse("'foo.bar'.baz = 'data'")
237235

238236
assert "Expected <= | <> | < | >= | > | == | = | !=, found '.'" in str(exc_info.value)
237+
238+
239+
def test_quoted_column_with_spaces() -> None:
240+
assert EqualTo("Foo Bar", "data") == parser.parse("\"Foo Bar\" = 'data'")

tests/integration/test_statistics_operations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ def create_statistics_file(snapshot_id: int, type_name: str) -> StatisticsFile:
8282
update.remove_statistics(add_snapshot_id_1)
8383

8484
assert len(tbl.metadata.statistics) == 1
85+
86+
with tbl.transaction() as txn:
87+
with txn.update_statistics() as update:
88+
update.set_statistics(statistics_file_snap_1)
89+
update.set_statistics(statistics_file_snap_2)
90+
91+
assert len(tbl.metadata.statistics) == 2

0 commit comments

Comments
 (0)