Skip to content

Commit 050ca87

Browse files
committed
fix: remove global id_generator in function registry
1 parent 1efb3f0 commit 050ca87

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/substrait/function_registry.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ def normalize_substrait_type_names(typ: str) -> str:
5050
return typ
5151

5252

53-
id_generator = itertools.count(1)
54-
55-
5653
def to_integer_option(txt: str):
5754
if txt.isnumeric():
5855
return ParameterizedType.IntegerOption(literal=int(txt))
@@ -153,7 +150,7 @@ def to_parameterized_type(dtype: str):
153150
user_defined=ParameterizedType.ParameterizedUserDefined()
154151
)
155152
else:
156-
raise Exception(f"Unkownn type - {dtype}")
153+
raise Exception(f"Unknown type - {dtype}")
157154

158155

159156
def violates_integer_option(
@@ -210,11 +207,11 @@ def covers(dtype: Type, parameterized_type: ParameterizedType, parameters: dict)
210207

211208

212209
class FunctionEntry:
213-
def __init__(self, uri: str, name: str, impl: Mapping[str, Any]) -> None:
210+
def __init__(self, uri: str, name: str, impl: Mapping[str, Any], anchor: int) -> None:
214211
self.name = name
215212
self.normalized_inputs: list = []
216213
self.uri: str = uri
217-
self.anchor = next(id_generator)
214+
self.anchor = anchor
218215
self.arguments = []
219216
self.rtn = impl["return"]
220217
self.nullability = impl.get("nullability", False)
@@ -286,7 +283,7 @@ def register_extension_dict(self, definitions: dict, uri: str) -> None:
286283
for named_functions in definitions.values():
287284
for function in named_functions:
288285
for impl in function.get("impls", []):
289-
func = FunctionEntry(uri, function["name"], impl)
286+
func = FunctionEntry(uri, function["name"], impl, next(self.id_generator))
290287
if (
291288
func.uri in self._function_mapping
292289
and function["name"] in self._function_mapping[func.uri]

0 commit comments

Comments
 (0)