Skip to content

Commit 7425bc4

Browse files
authored
Fix pyparsing diagnostic warning on Table import (#3081)
1 parent 3f37f56 commit 7425bc4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

pyiceberg/expressions/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _(result: ParseResults) -> Reference:
103103
return Reference(".".join(result.column))
104104

105105

106-
boolean = one_of(["true", "false"], caseless=True).set_results_name("boolean")
106+
boolean = one_of(["true", "false"], caseless=True)
107107
string = sgl_quoted_string.set_results_name("raw_quoted_string")
108108
decimal = common.real().set_results_name("decimal")
109109
integer = common.signed_integer().set_results_name("integer")
@@ -115,7 +115,7 @@ def _(result: ParseResults) -> Reference:
115115

116116
@boolean.set_parse_action
117117
def _(result: ParseResults) -> Literal[bool]:
118-
if strtobool(result.boolean):
118+
if strtobool(result[0]):
119119
return BooleanLiteral(True)
120120
else:
121121
return BooleanLiteral(False)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
import importlib
18+
19+
import pyparsing as pp
20+
21+
import pyiceberg.expressions.parser as parser
22+
import pyiceberg.table as table
23+
24+
25+
def test_table_import_has_no_ungrouped_named_tokens_warning() -> None:
26+
diagnostic = pp.Diagnostics.warn_ungrouped_named_tokens_in_collection
27+
was_enabled = pp.__diag__.warn_ungrouped_named_tokens_in_collection
28+
29+
pp.enable_diag(diagnostic)
30+
try:
31+
importlib.reload(parser)
32+
importlib.reload(table)
33+
finally:
34+
if not was_enabled:
35+
pp.disable_diag(diagnostic)

0 commit comments

Comments
 (0)