@@ -1241,7 +1241,8 @@ def visit_less_than(self, term: BoundTerm, literal: LiteralValue) -> bool:
12411241 if not isinstance (field .field_type , PrimitiveType ):
12421242 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
12431243
1244- if lower_bound_bytes := self .lower_bounds .get (field_id ):
1244+ lower_bound_bytes = self .lower_bounds .get (field_id )
1245+ if lower_bound_bytes is not None :
12451246 lower_bound = from_bytes (field .field_type , lower_bound_bytes )
12461247
12471248 if self ._is_nan (lower_bound ):
@@ -1263,7 +1264,8 @@ def visit_less_than_or_equal(self, term: BoundTerm, literal: LiteralValue) -> bo
12631264 if not isinstance (field .field_type , PrimitiveType ):
12641265 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
12651266
1266- if lower_bound_bytes := self .lower_bounds .get (field_id ):
1267+ lower_bound_bytes = self .lower_bounds .get (field_id )
1268+ if lower_bound_bytes is not None :
12671269 lower_bound = from_bytes (field .field_type , lower_bound_bytes )
12681270 if self ._is_nan (lower_bound ):
12691271 # NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
@@ -1284,7 +1286,8 @@ def visit_greater_than(self, term: BoundTerm, literal: LiteralValue) -> bool:
12841286 if not isinstance (field .field_type , PrimitiveType ):
12851287 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
12861288
1287- if upper_bound_bytes := self .upper_bounds .get (field_id ):
1289+ upper_bound_bytes = self .upper_bounds .get (field_id )
1290+ if upper_bound_bytes is not None :
12881291 upper_bound = from_bytes (field .field_type , upper_bound_bytes )
12891292 if upper_bound <= literal .value :
12901293 if self ._is_nan (upper_bound ):
@@ -1305,7 +1308,8 @@ def visit_greater_than_or_equal(self, term: BoundTerm, literal: LiteralValue) ->
13051308 if not isinstance (field .field_type , PrimitiveType ):
13061309 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
13071310
1308- if upper_bound_bytes := self .upper_bounds .get (field_id ):
1311+ upper_bound_bytes = self .upper_bounds .get (field_id )
1312+ if upper_bound_bytes is not None :
13091313 upper_bound = from_bytes (field .field_type , upper_bound_bytes )
13101314 if upper_bound < literal .value :
13111315 if self ._is_nan (upper_bound ):
@@ -1326,7 +1330,8 @@ def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> bool:
13261330 if not isinstance (field .field_type , PrimitiveType ):
13271331 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
13281332
1329- if lower_bound_bytes := self .lower_bounds .get (field_id ):
1333+ lower_bound_bytes = self .lower_bounds .get (field_id )
1334+ if lower_bound_bytes is not None :
13301335 lower_bound = from_bytes (field .field_type , lower_bound_bytes )
13311336 if self ._is_nan (lower_bound ):
13321337 # NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
@@ -1335,7 +1340,8 @@ def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> bool:
13351340 if lower_bound > literal .value :
13361341 return ROWS_CANNOT_MATCH
13371342
1338- if upper_bound_bytes := self .upper_bounds .get (field_id ):
1343+ upper_bound_bytes = self .upper_bounds .get (field_id )
1344+ if upper_bound_bytes is not None :
13391345 upper_bound = from_bytes (field .field_type , upper_bound_bytes )
13401346 if self ._is_nan (upper_bound ):
13411347 # NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
@@ -1363,7 +1369,8 @@ def visit_in(self, term: BoundTerm, literals: set[L]) -> bool:
13631369 if not isinstance (field .field_type , PrimitiveType ):
13641370 raise ValueError (f"Expected PrimitiveType: { field .field_type } " )
13651371
1366- if lower_bound_bytes := self .lower_bounds .get (field_id ):
1372+ lower_bound_bytes = self .lower_bounds .get (field_id )
1373+ if lower_bound_bytes is not None :
13671374 lower_bound = from_bytes (field .field_type , lower_bound_bytes )
13681375 if self ._is_nan (lower_bound ):
13691376 # NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
@@ -1373,7 +1380,8 @@ def visit_in(self, term: BoundTerm, literals: set[L]) -> bool:
13731380 if len (literals ) == 0 :
13741381 return ROWS_CANNOT_MATCH
13751382
1376- if upper_bound_bytes := self .upper_bounds .get (field_id ):
1383+ upper_bound_bytes = self .upper_bounds .get (field_id )
1384+ if upper_bound_bytes is not None :
13771385 upper_bound = from_bytes (field .field_type , upper_bound_bytes )
13781386 # this is different from Java, here NaN is always larger
13791387 if self ._is_nan (upper_bound ):
@@ -1403,14 +1411,16 @@ def visit_starts_with(self, term: BoundTerm, literal: LiteralValue) -> bool:
14031411 prefix = str (literal .value )
14041412 len_prefix = len (prefix )
14051413
1406- if lower_bound_bytes := self .lower_bounds .get (field_id ):
1414+ lower_bound_bytes = self .lower_bounds .get (field_id )
1415+ if lower_bound_bytes is not None :
14071416 lower_bound = str (from_bytes (field .field_type , lower_bound_bytes ))
14081417
14091418 # truncate lower bound so that its length is not greater than the length of prefix
14101419 if lower_bound and lower_bound [:len_prefix ] > prefix :
14111420 return ROWS_CANNOT_MATCH
14121421
1413- if upper_bound_bytes := self .upper_bounds .get (field_id ):
1422+ upper_bound_bytes = self .upper_bounds .get (field_id )
1423+ if upper_bound_bytes is not None :
14141424 upper_bound = str (from_bytes (field .field_type , upper_bound_bytes ))
14151425
14161426 # truncate upper bound so that its length is not greater than the length of prefix
@@ -1434,7 +1444,9 @@ def visit_not_starts_with(self, term: BoundTerm, literal: LiteralValue) -> bool:
14341444
14351445 # not_starts_with will match unless all values must start with the prefix. This happens when
14361446 # the lower and upper bounds both start with the prefix.
1437- if (lower_bound_bytes := self .lower_bounds .get (field_id )) and (upper_bound_bytes := self .upper_bounds .get (field_id )):
1447+ lower_bound_bytes = self .lower_bounds .get (field_id )
1448+ upper_bound_bytes = self .upper_bounds .get (field_id )
1449+ if lower_bound_bytes is not None and upper_bound_bytes is not None :
14381450 lower_bound = str (from_bytes (field .field_type , lower_bound_bytes ))
14391451 upper_bound = str (from_bytes (field .field_type , upper_bound_bytes ))
14401452
@@ -1558,7 +1570,8 @@ def visit_less_than(self, term: BoundTerm, literal: LiteralValue) -> bool:
15581570 if self ._can_contain_nulls (field_id ) or self ._can_contain_nans (field_id ):
15591571 return ROWS_MIGHT_NOT_MATCH
15601572
1561- if upper_bytes := self .upper_bounds .get (field_id ):
1573+ upper_bytes = self .upper_bounds .get (field_id )
1574+ if upper_bytes is not None :
15621575 field = self ._get_field (field_id )
15631576 upper = _from_byte_buffer (field .field_type , upper_bytes )
15641577
@@ -1575,7 +1588,8 @@ def visit_less_than_or_equal(self, term: BoundTerm, literal: LiteralValue) -> bo
15751588 if self ._can_contain_nulls (field_id ) or self ._can_contain_nans (field_id ):
15761589 return ROWS_MIGHT_NOT_MATCH
15771590
1578- if upper_bytes := self .upper_bounds .get (field_id ):
1591+ upper_bytes = self .upper_bounds .get (field_id )
1592+ if upper_bytes is not None :
15791593 field = self ._get_field (field_id )
15801594 upper = _from_byte_buffer (field .field_type , upper_bytes )
15811595
@@ -1592,7 +1606,8 @@ def visit_greater_than(self, term: BoundTerm, literal: LiteralValue) -> bool:
15921606 if self ._can_contain_nulls (field_id ) or self ._can_contain_nans (field_id ):
15931607 return ROWS_MIGHT_NOT_MATCH
15941608
1595- if lower_bytes := self .lower_bounds .get (field_id ):
1609+ lower_bytes = self .lower_bounds .get (field_id )
1610+ if lower_bytes is not None :
15961611 field = self ._get_field (field_id )
15971612 lower = _from_byte_buffer (field .field_type , lower_bytes )
15981613
@@ -1613,7 +1628,8 @@ def visit_greater_than_or_equal(self, term: BoundTerm, literal: LiteralValue) ->
16131628 if self ._can_contain_nulls (field_id ) or self ._can_contain_nans (field_id ):
16141629 return ROWS_MIGHT_NOT_MATCH
16151630
1616- if lower_bytes := self .lower_bounds .get (field_id ):
1631+ lower_bytes = self .lower_bounds .get (field_id )
1632+ if lower_bytes is not None :
16171633 field = self ._get_field (field_id )
16181634 lower = _from_byte_buffer (field .field_type , lower_bytes )
16191635
@@ -1634,7 +1650,9 @@ def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> bool:
16341650 if self ._can_contain_nulls (field_id ) or self ._can_contain_nans (field_id ):
16351651 return ROWS_MIGHT_NOT_MATCH
16361652
1637- if (lower_bytes := self .lower_bounds .get (field_id )) and (upper_bytes := self .upper_bounds .get (field_id )):
1653+ lower_bytes = self .lower_bounds .get (field_id )
1654+ upper_bytes = self .upper_bounds .get (field_id )
1655+ if lower_bytes is not None and upper_bytes is not None :
16381656 field = self ._get_field (field_id )
16391657 lower = _from_byte_buffer (field .field_type , lower_bytes )
16401658 upper = _from_byte_buffer (field .field_type , upper_bytes )
@@ -1655,7 +1673,8 @@ def visit_not_equal(self, term: BoundTerm, literal: LiteralValue) -> bool:
16551673
16561674 field = self ._get_field (field_id )
16571675
1658- if lower_bytes := self .lower_bounds .get (field_id ):
1676+ lower_bytes = self .lower_bounds .get (field_id )
1677+ if lower_bytes is not None :
16591678 lower = _from_byte_buffer (field .field_type , lower_bytes )
16601679
16611680 if self ._is_nan (lower ):
@@ -1666,7 +1685,8 @@ def visit_not_equal(self, term: BoundTerm, literal: LiteralValue) -> bool:
16661685 if lower > literal .value :
16671686 return ROWS_MUST_MATCH
16681687
1669- if upper_bytes := self .upper_bounds .get (field_id ):
1688+ upper_bytes = self .upper_bounds .get (field_id )
1689+ if upper_bytes is not None :
16701690 upper = _from_byte_buffer (field .field_type , upper_bytes )
16711691
16721692 if upper < literal .value :
@@ -1682,7 +1702,9 @@ def visit_in(self, term: BoundTerm, literals: set[L]) -> bool:
16821702
16831703 field = self ._get_field (field_id )
16841704
1685- if (lower_bytes := self .lower_bounds .get (field_id )) and (upper_bytes := self .upper_bounds .get (field_id )):
1705+ lower_bytes = self .lower_bounds .get (field_id )
1706+ upper_bytes = self .upper_bounds .get (field_id )
1707+ if lower_bytes is not None and upper_bytes is not None :
16861708 # similar to the implementation in eq, first check if the lower bound is in the set
16871709 lower = _from_byte_buffer (field .field_type , lower_bytes )
16881710 if lower not in literals :
@@ -1711,7 +1733,8 @@ def visit_not_in(self, term: BoundTerm, literals: set[L]) -> bool:
17111733
17121734 field = self ._get_field (field_id )
17131735
1714- if lower_bytes := self .lower_bounds .get (field_id ):
1736+ lower_bytes = self .lower_bounds .get (field_id )
1737+ if lower_bytes is not None :
17151738 lower = _from_byte_buffer (field .field_type , lower_bytes )
17161739
17171740 if self ._is_nan (lower ):
@@ -1723,7 +1746,8 @@ def visit_not_in(self, term: BoundTerm, literals: set[L]) -> bool:
17231746 if len (literals ) == 0 :
17241747 return ROWS_MUST_MATCH
17251748
1726- if upper_bytes := self .upper_bounds .get (field_id ):
1749+ upper_bytes = self .upper_bounds .get (field_id )
1750+ if upper_bytes is not None :
17271751 upper = _from_byte_buffer (field .field_type , upper_bytes )
17281752
17291753 literals = {val for val in literals if upper >= val }
0 commit comments