|
3 | 3 |
|
4 | 4 | import operator |
5 | 5 | from collections.abc import Callable |
| 6 | +from typing import TYPE_CHECKING |
6 | 7 |
|
7 | 8 | from google.protobuf.internal.containers import RepeatedCompositeFieldContainer |
8 | | -from substrait.gen.proto.algebra_pb2 import Expression, FunctionArgument |
9 | | -from substrait.gen.proto.extended_expression_pb2 import ExpressionReference, ExtendedExpression |
10 | | -from substrait.gen.proto.extensions.extensions_pb2 import SimpleExtensionDeclaration, SimpleExtensionURI |
11 | | -from substrait.gen.proto.type_pb2 import NamedStruct |
| 9 | + |
| 10 | +if TYPE_CHECKING: |
| 11 | + from substrait.algebra_pb2 import Expression, FunctionArgument |
| 12 | + from substrait.extended_expression_pb2 import ExpressionReference, ExtendedExpression |
| 13 | + from substrait.extensions.extensions_pb2 import ( |
| 14 | + SimpleExtensionDeclaration, |
| 15 | + SimpleExtensionURI, # pyright: ignore[reportDeprecated] |
| 16 | + ) |
| 17 | + from substrait.type_pb2 import NamedStruct |
| 18 | +else: |
| 19 | + try: |
| 20 | + # substrait >= 0.27 |
| 21 | + from substrait.algebra_pb2 import Expression, FunctionArgument |
| 22 | + from substrait.extended_expression_pb2 import ExpressionReference, ExtendedExpression |
| 23 | + from substrait.extensions.extensions_pb2 import SimpleExtensionDeclaration, SimpleExtensionURI |
| 24 | + from substrait.type_pb2 import NamedStruct |
| 25 | + except ImportError: |
| 26 | + # substrait < 0.27 |
| 27 | + from substrait.gen.proto.algebra_pb2 import Expression, FunctionArgument |
| 28 | + from substrait.gen.proto.extended_expression_pb2 import ExpressionReference, ExtendedExpression |
| 29 | + from substrait.gen.proto.extensions.extensions_pb2 import SimpleExtensionDeclaration, SimpleExtensionURI |
| 30 | + from substrait.gen.proto.type_pb2 import NamedStruct |
12 | 31 |
|
13 | 32 | from ._lib import dtype as _dtype # pyright: ignore[reportMissingModuleSource] |
14 | 33 | from ._lib import expr as _expr # pyright: ignore[reportMissingModuleSource] |
@@ -150,7 +169,7 @@ def function_argument( |
150 | 169 |
|
151 | 170 | def extension_function( |
152 | 171 | substrait_object: SimpleExtensionDeclaration.ExtensionFunction, |
153 | | - extension_uris: RepeatedCompositeFieldContainer[SimpleExtensionURI], |
| 172 | + extension_uris: RepeatedCompositeFieldContainer[SimpleExtensionURI], # pyright: ignore[reportDeprecated] |
154 | 173 | ) -> Callable[..., _expr.Expr]: |
155 | 174 | # https://github.com/substrait-io/substrait/blob/main/proto/substrait/extensions/extensions.proto#L57 |
156 | 175 | match extension_uris[substrait_object.extension_uri_reference].uri: |
|
0 commit comments