-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,509 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""A library to search Substrait plan for local files.""" | ||
from gateway.converter.substrait_plan_visitor import SubstraitPlanVisitor | ||
from substrait.gen.proto import plan_pb2 | ||
from substrait.gen.proto.extensions import extensions_pb2 | ||
|
||
|
||
# pylint: disable=E1101,no-member | ||
class AddExtensionUris(SubstraitPlanVisitor): | ||
"""Ensures that the plan has extension URI definitions for all references.""" | ||
|
||
def visit_plan(self, plan: plan_pb2.Plan) -> None: | ||
"""Modify the provided plan so that all functions have URI references.""" | ||
super().visit_plan(plan) | ||
|
||
known_uris: list[int] = [] | ||
for uri in plan.extension_uris: | ||
known_uris.append(uri.extension_uri_anchor) | ||
|
||
for extension in plan.extensions: | ||
if extension.WhichOneof('mapping_type') != 'extension_function': | ||
continue | ||
|
||
if extension.extension_function.extension_uri_reference not in known_uris: | ||
# TODO -- Make sure this hack occurs at most once. | ||
uri = extensions_pb2.SimpleExtensionURI( | ||
uri='urn:arrow:substrait_simple_extension_function', | ||
extension_uri_anchor=extension.extension_function.extension_uri_reference) | ||
plan.extension_uris.append(uri) | ||
known_uris.append(extension.extension_function.extension_uri_reference) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.