-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update sqlalchemy schema generation branch (#333)
* Add indexes (#312) * Added indexes to the SchemaGraph * Add additional index methods and remove type field * Nits * Nits * More nits * More nits * Changed all_indexes to indexes * Revert "Changed all_indexes to indexes" This reverts commit 44ffd00. * Nit * Addressed code review comments * Prohibit null value ignoring for edge indexes * Fix typo * Stop overriding ignore_nulls for edge indexes to true * Fix typo * Refactor inheritance structure constructor (#314) * Add immediate superclasses dict * Make toposorting not use OrientDB constructs. * Refactored InheritanceStructure constructor * Move inheritance structure class and related methods * Fixed docstring * Added documentation for InheritanceStructure class * Nits * Return validation to its original place * Fix terminology * More nits * More nits * More nits * Re-add list coercion * Add indexes to test SchemaGraph (#315) * Add indexes to test SchemaGraph * Changed sets arguments to lists and remove is None check * Add output info to query metadata (#311) * Add output info to query metadata * Update explain info tests * Add output tests to explain_info * Remove context output * Add docstring metadata outputs property * Use query_metadta_table variable and name * Replace more names with query_metadata_table * Remove fold from OutputInfo * Change set input for list input (#318) * Fix index documentation (#321) * Fix index documentation * Nit * Refactor and clean up IR lowering code. Add common IR lowering module. (#324) * Refactor and clean up IR lowering code. Add common IR lowering operations module. * Delint. * Improve expression comment around null values. * Add defensive strip_non_null_from_type() call. * Fix inheritance of SQLAlchemy vertices
- Loading branch information
1 parent
258577e
commit 1f91f84
Showing
23 changed files
with
811 additions
and
403 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Copyright 2019-present Kensho Technologies, LLC. |
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
67 changes: 67 additions & 0 deletions
67
graphql_compiler/compiler/ir_lowering_common/location_renaming.py
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,67 @@ | ||
# Copyright 2019-present Kensho Technologies, LLC. | ||
"""Utilities for rewriting IR to replace one set of locations with another.""" | ||
import six | ||
|
||
from ..helpers import FoldScopeLocation, Location | ||
|
||
|
||
def make_revisit_location_translations(query_metadata_table): | ||
"""Return a dict mapping location revisits to the location being revisited, for rewriting.""" | ||
location_translations = dict() | ||
|
||
for location, _ in query_metadata_table.registered_locations: | ||
location_being_revisited = query_metadata_table.get_revisit_origin(location) | ||
if location_being_revisited != location: | ||
location_translations[location] = location_being_revisited | ||
|
||
return location_translations | ||
|
||
|
||
def translate_potential_location(location_translations, potential_location): | ||
"""If the input is a BaseLocation object, translate it, otherwise return it as-is.""" | ||
if isinstance(potential_location, Location): | ||
old_location_at_vertex = potential_location.at_vertex() | ||
field = potential_location.field | ||
|
||
new_location = location_translations.get(old_location_at_vertex, None) | ||
if new_location is None: | ||
# No translation needed. | ||
return potential_location | ||
else: | ||
# If necessary, add the field component to the new location before returning it. | ||
if field is None: | ||
return new_location | ||
else: | ||
return new_location.navigate_to_field(field) | ||
elif isinstance(potential_location, FoldScopeLocation): | ||
old_base_location = potential_location.base_location | ||
new_base_location = location_translations.get(old_base_location, old_base_location) | ||
fold_path = potential_location.fold_path | ||
fold_field = potential_location.field | ||
return FoldScopeLocation(new_base_location, fold_path, field=fold_field) | ||
else: | ||
return potential_location | ||
|
||
|
||
def make_location_rewriter_visitor_fn(location_translations): | ||
"""Return a visitor function that is able to replace locations with equivalent locations.""" | ||
def visitor_fn(expression): | ||
"""Expression visitor function used to rewrite expressions with updated Location data.""" | ||
# All CompilerEntity objects store their exact constructor input args/kwargs. | ||
# To minimize the chances that we forget to update a location somewhere in an expression, | ||
# we rewrite all locations that we find as arguments to expression constructors. | ||
# pylint: disable=protected-access | ||
new_args = [ | ||
translate_potential_location(location_translations, arg) | ||
for arg in expression._print_args | ||
] | ||
new_kwargs = { | ||
kwarg_name: translate_potential_location(location_translations, kwarg_value) | ||
for kwarg_name, kwarg_value in six.iteritems(expression._print_kwargs) | ||
} | ||
# pylint: enable=protected-access | ||
|
||
expression_cls = type(expression) | ||
return expression_cls(*new_args, **new_kwargs) | ||
|
||
return visitor_fn |
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.