id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
233,000
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
TernaryConditional.validate
def validate(self): """Validate that the TernaryConditional is correctly representable.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate)) if not isinst...
python
def validate(self): """Validate that the TernaryConditional is correctly representable.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate)) if not isinst...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "predicate", ",", "Expression", ")", ":", "raise", "TypeError", "(", "u'Expected Expression predicate, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "predicate...
Validate that the TernaryConditional is correctly representable.
[ "Validate", "that", "the", "TernaryConditional", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L893-L903
233,001
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
TernaryConditional.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this TernaryConditional.""" self.validate() # For MATCH, an additional validation step is needed -- we currently do not support # emitting MATCH code for TernaryConditional that contains another TernaryCondi...
python
def to_match(self): """Return a unicode object with the MATCH representation of this TernaryConditional.""" self.validate() # For MATCH, an additional validation step is needed -- we currently do not support # emitting MATCH code for TernaryConditional that contains another TernaryCondi...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "# For MATCH, an additional validation step is needed -- we currently do not support", "# emitting MATCH code for TernaryConditional that contains another TernaryConditional", "# anywhere within the predicate expr...
Return a unicode object with the MATCH representation of this TernaryConditional.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "TernaryConditional", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L918-L945
233,002
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
sanity_check_ir_blocks_from_frontend
def sanity_check_ir_blocks_from_frontend(ir_blocks, query_metadata_table): """Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected str...
python
def sanity_check_ir_blocks_from_frontend(ir_blocks, query_metadata_table): """Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected str...
[ "def", "sanity_check_ir_blocks_from_frontend", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "if", "not", "ir_blocks", ":", "raise", "AssertionError", "(", "u'Received no ir_blocks: {}'", ".", "format", "(", "ir_blocks", ")", ")", "_sanity_check_fold_scope_loca...
Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected structure. If the IR produced by the front-end cannot be successfully and cor...
[ "Assert", "that", "IR", "blocks", "originating", "from", "the", "frontend", "do", "not", "have", "nonsensical", "structure", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L13-L36
233,003
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_registered_locations_parent_locations
def _sanity_check_registered_locations_parent_locations(query_metadata_table): """Assert that all registered locations' parent locations are also registered.""" for location, location_info in query_metadata_table.registered_locations: if (location != query_metadata_table.root_location and ...
python
def _sanity_check_registered_locations_parent_locations(query_metadata_table): """Assert that all registered locations' parent locations are also registered.""" for location, location_info in query_metadata_table.registered_locations: if (location != query_metadata_table.root_location and ...
[ "def", "_sanity_check_registered_locations_parent_locations", "(", "query_metadata_table", ")", ":", "for", "location", ",", "location_info", "in", "query_metadata_table", ".", "registered_locations", ":", "if", "(", "location", "!=", "query_metadata_table", ".", "root_loca...
Assert that all registered locations' parent locations are also registered.
[ "Assert", "that", "all", "registered", "locations", "parent", "locations", "are", "also", "registered", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L39-L54
233,004
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_all_marked_locations_are_registered
def _sanity_check_all_marked_locations_are_registered(ir_blocks, query_metadata_table): """Assert that all locations in MarkLocation blocks have registered and valid metadata.""" # Grab all the registered locations, then make sure that: # - Any location that appears in a MarkLocation block is also registere...
python
def _sanity_check_all_marked_locations_are_registered(ir_blocks, query_metadata_table): """Assert that all locations in MarkLocation blocks have registered and valid metadata.""" # Grab all the registered locations, then make sure that: # - Any location that appears in a MarkLocation block is also registere...
[ "def", "_sanity_check_all_marked_locations_are_registered", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "# Grab all the registered locations, then make sure that:", "# - Any location that appears in a MarkLocation block is also registered.", "# - There are no registered locations th...
Assert that all locations in MarkLocation blocks have registered and valid metadata.
[ "Assert", "that", "all", "locations", "in", "MarkLocation", "blocks", "have", "registered", "and", "valid", "metadata", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L57-L80
233,005
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_fold_scope_locations_are_unique
def _sanity_check_fold_scope_locations_are_unique(ir_blocks): """Assert that every FoldScopeLocation that exists on a Fold block is unique.""" observed_locations = dict() for block in ir_blocks: if isinstance(block, Fold): alternate = observed_locations.get(block.fold_scope_location, Non...
python
def _sanity_check_fold_scope_locations_are_unique(ir_blocks): """Assert that every FoldScopeLocation that exists on a Fold block is unique.""" observed_locations = dict() for block in ir_blocks: if isinstance(block, Fold): alternate = observed_locations.get(block.fold_scope_location, Non...
[ "def", "_sanity_check_fold_scope_locations_are_unique", "(", "ir_blocks", ")", ":", "observed_locations", "=", "dict", "(", ")", "for", "block", "in", "ir_blocks", ":", "if", "isinstance", "(", "block", ",", "Fold", ")", ":", "alternate", "=", "observed_locations"...
Assert that every FoldScopeLocation that exists on a Fold block is unique.
[ "Assert", "that", "every", "FoldScopeLocation", "that", "exists", "on", "a", "Fold", "block", "is", "unique", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L83-L92
233,006
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_no_nested_folds
def _sanity_check_no_nested_folds(ir_blocks): """Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.""" fold_seen = False for block in ir_blocks: if isinstance(block, Fold): if fold_seen: raise AssertionError(u'Found a nested Fold con...
python
def _sanity_check_no_nested_folds(ir_blocks): """Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.""" fold_seen = False for block in ir_blocks: if isinstance(block, Fold): if fold_seen: raise AssertionError(u'Found a nested Fold con...
[ "def", "_sanity_check_no_nested_folds", "(", "ir_blocks", ")", ":", "fold_seen", "=", "False", "for", "block", "in", "ir_blocks", ":", "if", "isinstance", "(", "block", ",", "Fold", ")", ":", "if", "fold_seen", ":", "raise", "AssertionError", "(", "u'Found a n...
Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.
[ "Assert", "that", "there", "are", "no", "nested", "Fold", "contexts", "and", "that", "every", "Fold", "has", "a", "matching", "Unfold", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L95-L109
233,007
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_query_root_block
def _sanity_check_query_root_block(ir_blocks): """Assert that QueryRoot is always the first block, and only the first block.""" if not isinstance(ir_blocks[0], QueryRoot): raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks)) for block in ir_blocks[1:]: if isinstan...
python
def _sanity_check_query_root_block(ir_blocks): """Assert that QueryRoot is always the first block, and only the first block.""" if not isinstance(ir_blocks[0], QueryRoot): raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks)) for block in ir_blocks[1:]: if isinstan...
[ "def", "_sanity_check_query_root_block", "(", "ir_blocks", ")", ":", "if", "not", "isinstance", "(", "ir_blocks", "[", "0", "]", ",", "QueryRoot", ")", ":", "raise", "AssertionError", "(", "u'The first block was not QueryRoot: {}'", ".", "format", "(", "ir_blocks", ...
Assert that QueryRoot is always the first block, and only the first block.
[ "Assert", "that", "QueryRoot", "is", "always", "the", "first", "block", "and", "only", "the", "first", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L112-L118
233,008
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_construct_result_block
def _sanity_check_construct_result_block(ir_blocks): """Assert that ConstructResult is always the last block, and only the last block.""" if not isinstance(ir_blocks[-1], ConstructResult): raise AssertionError(u'The last block was not ConstructResult: {}'.format(ir_blocks)) for block in ir_blocks[:-...
python
def _sanity_check_construct_result_block(ir_blocks): """Assert that ConstructResult is always the last block, and only the last block.""" if not isinstance(ir_blocks[-1], ConstructResult): raise AssertionError(u'The last block was not ConstructResult: {}'.format(ir_blocks)) for block in ir_blocks[:-...
[ "def", "_sanity_check_construct_result_block", "(", "ir_blocks", ")", ":", "if", "not", "isinstance", "(", "ir_blocks", "[", "-", "1", "]", ",", "ConstructResult", ")", ":", "raise", "AssertionError", "(", "u'The last block was not ConstructResult: {}'", ".", "format"...
Assert that ConstructResult is always the last block, and only the last block.
[ "Assert", "that", "ConstructResult", "is", "always", "the", "last", "block", "and", "only", "the", "last", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L121-L128
233,009
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_block_pairwise_constraints
def _sanity_check_block_pairwise_constraints(ir_blocks): """Assert that adjacent blocks obey all invariants.""" for first_block, second_block in pairwise(ir_blocks): # Always Filter before MarkLocation, never after. if isinstance(first_block, MarkLocation) and isinstance(second_block, Filter): ...
python
def _sanity_check_block_pairwise_constraints(ir_blocks): """Assert that adjacent blocks obey all invariants.""" for first_block, second_block in pairwise(ir_blocks): # Always Filter before MarkLocation, never after. if isinstance(first_block, MarkLocation) and isinstance(second_block, Filter): ...
[ "def", "_sanity_check_block_pairwise_constraints", "(", "ir_blocks", ")", ":", "for", "first_block", ",", "second_block", "in", "pairwise", "(", "ir_blocks", ")", ":", "# Always Filter before MarkLocation, never after.", "if", "isinstance", "(", "first_block", ",", "MarkL...
Assert that adjacent blocks obey all invariants.
[ "Assert", "that", "adjacent", "blocks", "obey", "all", "invariants", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L144-L172
233,010
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_mark_location_preceding_optional_traverse
def _sanity_check_mark_location_preceding_optional_traverse(ir_blocks): """Assert that optional Traverse blocks are preceded by a MarkLocation.""" # Once all fold blocks are removed, each optional Traverse must have # a MarkLocation block immediately before it. _, new_ir_blocks = extract_folds_from_ir_b...
python
def _sanity_check_mark_location_preceding_optional_traverse(ir_blocks): """Assert that optional Traverse blocks are preceded by a MarkLocation.""" # Once all fold blocks are removed, each optional Traverse must have # a MarkLocation block immediately before it. _, new_ir_blocks = extract_folds_from_ir_b...
[ "def", "_sanity_check_mark_location_preceding_optional_traverse", "(", "ir_blocks", ")", ":", "# Once all fold blocks are removed, each optional Traverse must have", "# a MarkLocation block immediately before it.", "_", ",", "new_ir_blocks", "=", "extract_folds_from_ir_blocks", "(", "ir_...
Assert that optional Traverse blocks are preceded by a MarkLocation.
[ "Assert", "that", "optional", "Traverse", "blocks", "are", "preceded", "by", "a", "MarkLocation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L175-L185
233,011
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_every_location_is_marked
def _sanity_check_every_location_is_marked(ir_blocks): """Ensure that every new location is marked with a MarkLocation block.""" # Exactly one MarkLocation block is found between any block that starts an interval of blocks # that all affect the same query position, and the first subsequent block that affect...
python
def _sanity_check_every_location_is_marked(ir_blocks): """Ensure that every new location is marked with a MarkLocation block.""" # Exactly one MarkLocation block is found between any block that starts an interval of blocks # that all affect the same query position, and the first subsequent block that affect...
[ "def", "_sanity_check_every_location_is_marked", "(", "ir_blocks", ")", ":", "# Exactly one MarkLocation block is found between any block that starts an interval of blocks", "# that all affect the same query position, and the first subsequent block that affects a", "# different position in the query...
Ensure that every new location is marked with a MarkLocation block.
[ "Ensure", "that", "every", "new", "location", "is", "marked", "with", "a", "MarkLocation", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L188-L216
233,012
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_coerce_type_outside_of_fold
def _sanity_check_coerce_type_outside_of_fold(ir_blocks): """Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.""" is_in_fold = False for first_block, second_block in pairwise(ir_blocks): if isinstance(first_block, Fold): is_in_fold = True if n...
python
def _sanity_check_coerce_type_outside_of_fold(ir_blocks): """Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.""" is_in_fold = False for first_block, second_block in pairwise(ir_blocks): if isinstance(first_block, Fold): is_in_fold = True if n...
[ "def", "_sanity_check_coerce_type_outside_of_fold", "(", "ir_blocks", ")", ":", "is_in_fold", "=", "False", "for", "first_block", ",", "second_block", "in", "pairwise", "(", "ir_blocks", ")", ":", "if", "isinstance", "(", "first_block", ",", "Fold", ")", ":", "i...
Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.
[ "Ensure", "that", "CoerceType", "not", "in", "a" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L219-L232
233,013
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
validate_supported_property_type_id
def validate_supported_property_type_id(property_name, property_type_id): """Ensure that the given property type_id is supported by the graph.""" if property_type_id not in PROPERTY_TYPE_ID_TO_NAME: raise AssertionError(u'Property "{}" has unsupported property type id: ' u'{...
python
def validate_supported_property_type_id(property_name, property_type_id): """Ensure that the given property type_id is supported by the graph.""" if property_type_id not in PROPERTY_TYPE_ID_TO_NAME: raise AssertionError(u'Property "{}" has unsupported property type id: ' u'{...
[ "def", "validate_supported_property_type_id", "(", "property_name", ",", "property_type_id", ")", ":", "if", "property_type_id", "not", "in", "PROPERTY_TYPE_ID_TO_NAME", ":", "raise", "AssertionError", "(", "u'Property \"{}\" has unsupported property type id: '", "u'{}'", ".", ...
Ensure that the given property type_id is supported by the graph.
[ "Ensure", "that", "the", "given", "property", "type_id", "is", "supported", "by", "the", "graph", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L96-L100
233,014
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_bool_default_value
def _parse_bool_default_value(property_name, default_value_string): """Parse and return the default value for a boolean property.""" lowercased_value_string = default_value_string.lower() if lowercased_value_string in {'0', 'false'}: return False elif lowercased_value_string in {'1', 'true'}: ...
python
def _parse_bool_default_value(property_name, default_value_string): """Parse and return the default value for a boolean property.""" lowercased_value_string = default_value_string.lower() if lowercased_value_string in {'0', 'false'}: return False elif lowercased_value_string in {'1', 'true'}: ...
[ "def", "_parse_bool_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "lowercased_value_string", "=", "default_value_string", ".", "lower", "(", ")", "if", "lowercased_value_string", "in", "{", "'0'", ",", "'false'", "}", ":", "return", "F...
Parse and return the default value for a boolean property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "boolean", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L103-L112
233,015
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_datetime_default_value
def _parse_datetime_default_value(property_name, default_value_string): """Parse and return the default value for a datetime property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception ...
python
def _parse_datetime_default_value(property_name, default_value_string): """Parse and return the default value for a datetime property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception ...
[ "def", "_parse_datetime_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "# OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually", "# and then turn it into a python datetime object. strptime() will raise an exception", "# if the provided valu...
Parse and return the default value for a datetime property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "datetime", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L115-L123
233,016
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_date_default_value
def _parse_date_default_value(property_name, default_value_string): """Parse and return the default value for a date property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception # if the...
python
def _parse_date_default_value(property_name, default_value_string): """Parse and return the default value for a date property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception # if the...
[ "def", "_parse_date_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "# OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually", "# and then turn it into a python datetime object. strptime() will raise an exception", "# if the provided value ca...
Parse and return the default value for a date property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "date", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L126-L132
233,017
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
parse_default_property_value
def parse_default_property_value(property_name, property_type_id, default_value_string): """Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to...
python
def parse_default_property_value(property_name, property_type_id, default_value_string): """Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to...
[ "def", "parse_default_property_value", "(", "property_name", ",", "property_type_id", ",", "default_value_string", ")", ":", "if", "property_type_id", "==", "PROPERTY_TYPE_EMBEDDED_SET_ID", "and", "default_value_string", "==", "'{}'", ":", "return", "set", "(", ")", "el...
Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to construct meaningful error messages, should the default value prove inva...
[ "Parse", "the", "default", "value", "string", "into", "its", "proper", "form", "given", "the", "property", "type", "ID", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L135-L171
233,018
kensho-technologies/graphql-compiler
graphql_compiler/compiler/common.py
_compile_graphql_generic
def _compile_graphql_generic(language, lowering_func, query_emitter_func, schema, graphql_string, type_equivalence_hints, compiler_metadata): """Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the targe...
python
def _compile_graphql_generic(language, lowering_func, query_emitter_func, schema, graphql_string, type_equivalence_hints, compiler_metadata): """Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the targe...
[ "def", "_compile_graphql_generic", "(", "language", ",", "lowering_func", ",", "query_emitter_func", ",", "schema", ",", "graphql_string", ",", "type_equivalence_hints", ",", "compiler_metadata", ")", ":", "ir_and_metadata", "=", "graphql_to_ir", "(", "schema", ",", "...
Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the target language to compile to. lowering_func: Function to lower the compiler IR into a compatible form for the target language backend. query_em...
[ "Compile", "the", "GraphQL", "input", "lowering", "and", "emitting", "the", "query", "using", "the", "given", "functions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/common.py#L122-L152
233,019
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
scalar_leaf_only
def scalar_leaf_only(operator): """Ensure the filter function is only applied to scalar leaf types.""" def decorator(f): """Decorate the supplied function with the "scalar_leaf_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
python
def scalar_leaf_only(operator): """Ensure the filter function is only applied to scalar leaf types.""" def decorator(f): """Decorate the supplied function with the "scalar_leaf_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
[ "def", "scalar_leaf_only", "(", "operator", ")", ":", "def", "decorator", "(", "f", ")", ":", "\"\"\"Decorate the supplied function with the \"scalar_leaf_only\" logic.\"\"\"", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "context", ...
Ensure the filter function is only applied to scalar leaf types.
[ "Ensure", "the", "filter", "function", "is", "only", "applied", "to", "scalar", "leaf", "types", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L17-L37
233,020
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
vertex_field_only
def vertex_field_only(operator): """Ensure the filter function is only applied to vertex field types.""" def decorator(f): """Decorate the supplied function with the "vertex_field_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
python
def vertex_field_only(operator): """Ensure the filter function is only applied to vertex field types.""" def decorator(f): """Decorate the supplied function with the "vertex_field_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
[ "def", "vertex_field_only", "(", "operator", ")", ":", "def", "decorator", "(", "f", ")", ":", "\"\"\"Decorate the supplied function with the \"vertex_field_only\" logic.\"\"\"", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "context"...
Ensure the filter function is only applied to vertex field types.
[ "Ensure", "the", "filter", "function", "is", "only", "applied", "to", "vertex", "field", "types", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L40-L61
233,021
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
takes_parameters
def takes_parameters(count): """Ensure the filter function has "count" parameters specified.""" def decorator(f): """Decorate the supplied function with the "takes_parameters" logic.""" @wraps(f) def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs): ...
python
def takes_parameters(count): """Ensure the filter function has "count" parameters specified.""" def decorator(f): """Decorate the supplied function with the "takes_parameters" logic.""" @wraps(f) def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs): ...
[ "def", "takes_parameters", "(", "count", ")", ":", "def", "decorator", "(", "f", ")", ":", "\"\"\"Decorate the supplied function with the \"takes_parameters\" logic.\"\"\"", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "location", ...
Ensure the filter function has "count" parameters specified.
[ "Ensure", "the", "filter", "function", "has", "count", "parameters", "specified", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L64-L79
233,022
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_represent_argument
def _represent_argument(directive_location, context, argument, inferred_type): """Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared ...
python
def _represent_argument(directive_location, context, argument, inferred_type): """Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared ...
[ "def", "_represent_argument", "(", "directive_location", ",", "context", ",", "argument", ",", "inferred_type", ")", ":", "# Regardless of what kind of variable we are dealing with,", "# we want to ensure its name is valid.", "argument_name", "=", "argument", "[", "1", ":", "...
Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared tags, whether the current block is optional, etc.). May be mutated in...
[ "Return", "a", "two", "-", "element", "tuple", "that", "represents", "the", "argument", "to", "the", "directive", "being", "processed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L82-L156
233,023
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_comparison_filter_directive
def _process_comparison_filter_directive(filter_operation_info, location, context, parameters, operator=None): """Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, ...
python
def _process_comparison_filter_directive(filter_operation_info, location, context, parameters, operator=None): """Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, ...
[ "def", "_process_comparison_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ",", "operator", "=", "None", ")", ":", "comparison_operators", "=", "{", "u'='", ",", "u'!='", ",", "u'>'", ",", "u'<'", ",", "u'>='...
Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fi...
[ "Return", "a", "Filter", "basic", "block", "that", "performs", "the", "given", "comparison", "against", "the", "property", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L161-L204
233,024
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_has_edge_degree_filter_directive
def _process_has_edge_degree_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_has_edge_degree_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_has_edge_degree_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "if", "isinstance", "(", "filter_operation_info", ".", "field_ast", ",", "InlineFragment", ")", ":", "raise", "AssertionError"...
Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fil...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "the", "degree", "of", "the", "edge", "to", "the", "given", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L209-L279
233,025
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_name_or_alias_filter_directive
def _process_name_or_alias_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_name_or_alias_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_name_or_alias_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "if", "isinstance", "(", "filtered_field_type", ",", "Grap...
Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "for", "a", "match", "against", "an", "Entity", "s", "name", "or", "alias", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L284-L346
233,026
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_between_filter_directive
def _process_between_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_between_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_between_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "field_n...
Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "that", "a", "field", "is", "between", "two", "values", "inclusive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L351-L392
233,027
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_in_collection_filter_directive
def _process_in_collection_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_in_collection_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_in_collection_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "f...
Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter is us...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "for", "a", "value", "s", "existence", "in", "a", "collection", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L397-L427
233,028
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_has_substring_filter_directive
def _process_has_substring_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_has_substring_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_has_substring_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "f...
Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fil...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "is", "a", "substring", "of", "the", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L432-L466
233,029
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_contains_filter_directive
def _process_contains_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_contains_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_contains_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "field_...
Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filte...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "is", "contained", "in", "the", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L470-L505
233,030
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_intersects_filter_directive
def _process_intersects_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_intersects_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_intersects_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "fiel...
Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter ...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "and", "the", "field", "intersect", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L509-L543
233,031
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
is_filter_with_outer_scope_vertex_field_operator
def is_filter_with_outer_scope_vertex_field_operator(directive): """Return True if we have a filter directive whose operator applies to the outer scope.""" if directive.name.value != 'filter': return False op_name, _ = _get_filter_op_name_and_values(directive) return op_name in OUTER_SCOPE_VERT...
python
def is_filter_with_outer_scope_vertex_field_operator(directive): """Return True if we have a filter directive whose operator applies to the outer scope.""" if directive.name.value != 'filter': return False op_name, _ = _get_filter_op_name_and_values(directive) return op_name in OUTER_SCOPE_VERT...
[ "def", "is_filter_with_outer_scope_vertex_field_operator", "(", "directive", ")", ":", "if", "directive", ".", "name", ".", "value", "!=", "'filter'", ":", "return", "False", "op_name", ",", "_", "=", "_get_filter_op_name_and_values", "(", "directive", ")", "return"...
Return True if we have a filter directive whose operator applies to the outer scope.
[ "Return", "True", "if", "we", "have", "a", "filter", "directive", "whose", "operator", "applies", "to", "the", "outer", "scope", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L598-L604
233,032
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
process_filter_directive
def process_filter_directive(filter_operation_info, location, context): """Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field ...
python
def process_filter_directive(filter_operation_info, location, context): """Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field ...
[ "def", "process_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ")", ":", "op_name", ",", "operator_params", "=", "_get_filter_op_name_and_values", "(", "filter_operation_info", ".", "directive", ")", "non_comparison_filters", "=", "{", ...
Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "corresponds", "to", "the", "filter", "operation", "in", "the", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L607-L663
233,033
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_schema_type_name
def get_schema_type_name(node, context): """Return the GraphQL type name of a node.""" query_path = node.query_path if query_path not in context.query_path_to_location_info: raise AssertionError( u'Unable to find type name for query path {} with context {}.'.format( query...
python
def get_schema_type_name(node, context): """Return the GraphQL type name of a node.""" query_path = node.query_path if query_path not in context.query_path_to_location_info: raise AssertionError( u'Unable to find type name for query path {} with context {}.'.format( query...
[ "def", "get_schema_type_name", "(", "node", ",", "context", ")", ":", "query_path", "=", "node", ".", "query_path", "if", "query_path", "not", "in", "context", ".", "query_path_to_location_info", ":", "raise", "AssertionError", "(", "u'Unable to find type name for que...
Return the GraphQL type name of a node.
[ "Return", "the", "GraphQL", "type", "name", "of", "a", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L5-L13
233,034
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_node_at_path
def get_node_at_path(query_path, context): """Return the SqlNode associated with the query path.""" if query_path not in context.query_path_to_node: raise AssertionError( u'Unable to find SqlNode for query path {} with context {}.'.format( query_path, context)) node = con...
python
def get_node_at_path(query_path, context): """Return the SqlNode associated with the query path.""" if query_path not in context.query_path_to_node: raise AssertionError( u'Unable to find SqlNode for query path {} with context {}.'.format( query_path, context)) node = con...
[ "def", "get_node_at_path", "(", "query_path", ",", "context", ")", ":", "if", "query_path", "not", "in", "context", ".", "query_path_to_node", ":", "raise", "AssertionError", "(", "u'Unable to find SqlNode for query path {} with context {}.'", ".", "format", "(", "query...
Return the SqlNode associated with the query path.
[ "Return", "the", "SqlNode", "associated", "with", "the", "query", "path", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L27-L34
233,035
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
try_get_column
def try_get_column(column_name, node, context): """Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Ret...
python
def try_get_column(column_name, node, context): """Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Ret...
[ "def", "try_get_column", "(", "column_name", ",", "node", ",", "context", ")", ":", "selectable", "=", "get_node_selectable", "(", "node", ",", "context", ")", "if", "not", "hasattr", "(", "selectable", ",", "'c'", ")", ":", "raise", "AssertionError", "(", ...
Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: Optional[column], the SQLAlchemy column i...
[ "Attempt", "to", "get", "a", "column", "by", "name", "from", "the", "selectable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L37-L53
233,036
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_column
def get_column(column_name, node, context): """Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: c...
python
def get_column(column_name, node, context): """Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: c...
[ "def", "get_column", "(", "column_name", ",", "node", ",", "context", ")", ":", "column", "=", "try_get_column", "(", "column_name", ",", "node", ",", "context", ")", "if", "column", "is", "None", ":", "selectable", "=", "get_node_selectable", "(", "node", ...
Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: column, the SQLAlchemy column if found. Raises an As...
[ "Get", "a", "column", "by", "name", "from", "the", "selectable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L56-L74
233,037
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
get_unique_directives
def get_unique_directives(ast): """Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCo...
python
def get_unique_directives(ast): """Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCo...
[ "def", "get_unique_directives", "(", "ast", ")", ":", "if", "not", "ast", ".", "directives", ":", "return", "dict", "(", ")", "result", "=", "dict", "(", ")", "for", "directive_obj", "in", "ast", ".", "directives", ":", "directive_name", "=", "directive_ob...
Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCompilationError in case we find them mor...
[ "Return", "a", "dict", "of", "directive", "name", "to", "directive", "object", "for", "the", "given", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L27-L54
233,038
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
get_local_filter_directives
def get_local_filter_directives(ast, current_schema_type, inner_vertex_fields): """Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applie...
python
def get_local_filter_directives(ast, current_schema_type, inner_vertex_fields): """Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applie...
[ "def", "get_local_filter_directives", "(", "ast", ",", "current_schema_type", ",", "inner_vertex_fields", ")", ":", "result", "=", "[", "]", "if", "ast", ".", "directives", ":", "# it'll be None if the AST has no directives at that node", "for", "directive_obj", "in", "...
Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applied), whereas some apply on the outer scope (the scope that contains the inner vertex...
[ "Get", "all", "filter", "directives", "that", "apply", "to", "the", "current", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L57-L121
233,039
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_property_directives
def validate_property_directives(directives): """Validate the directives that appear at a property field.""" for directive_name in six.iterkeys(directives): if directive_name in VERTEX_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found vertex-only directive {} set on pro...
python
def validate_property_directives(directives): """Validate the directives that appear at a property field.""" for directive_name in six.iterkeys(directives): if directive_name in VERTEX_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found vertex-only directive {} set on pro...
[ "def", "validate_property_directives", "(", "directives", ")", ":", "for", "directive_name", "in", "six", ".", "iterkeys", "(", "directives", ")", ":", "if", "directive_name", "in", "VERTEX_ONLY_DIRECTIVES", ":", "raise", "GraphQLCompilationError", "(", "u'Found verte...
Validate the directives that appear at a property field.
[ "Validate", "the", "directives", "that", "appear", "at", "a", "property", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L124-L129
233,040
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_directives
def validate_vertex_directives(directives): """Validate the directives that appear at a vertex field.""" for directive_name in six.iterkeys(directives): if directive_name in PROPERTY_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found property-only directive {} set on ver...
python
def validate_vertex_directives(directives): """Validate the directives that appear at a vertex field.""" for directive_name in six.iterkeys(directives): if directive_name in PROPERTY_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found property-only directive {} set on ver...
[ "def", "validate_vertex_directives", "(", "directives", ")", ":", "for", "directive_name", "in", "six", ".", "iterkeys", "(", "directives", ")", ":", "if", "directive_name", "in", "PROPERTY_ONLY_DIRECTIVES", ":", "raise", "GraphQLCompilationError", "(", "u'Found prope...
Validate the directives that appear at a vertex field.
[ "Validate", "the", "directives", "that", "appear", "at", "a", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L132-L137
233,041
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_root_vertex_directives
def validate_root_vertex_directives(root_ast): """Validate the directives that appear at the root vertex field.""" directives_present_at_root = set() for directive_obj in root_ast.directives: directive_name = directive_obj.name.value if is_filter_with_outer_scope_vertex_field_operator(direc...
python
def validate_root_vertex_directives(root_ast): """Validate the directives that appear at the root vertex field.""" directives_present_at_root = set() for directive_obj in root_ast.directives: directive_name = directive_obj.name.value if is_filter_with_outer_scope_vertex_field_operator(direc...
[ "def", "validate_root_vertex_directives", "(", "root_ast", ")", ":", "directives_present_at_root", "=", "set", "(", ")", "for", "directive_obj", "in", "root_ast", ".", "directives", ":", "directive_name", "=", "directive_obj", ".", "name", ".", "value", "if", "is_...
Validate the directives that appear at the root vertex field.
[ "Validate", "the", "directives", "that", "appear", "at", "the", "root", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L140-L155
233,042
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_field_directive_interactions
def validate_vertex_field_directive_interactions(parent_location, vertex_field_name, directives): """Ensure that the specified vertex field directives are not mutually disallowed.""" fold_directive = directives.get('fold', None) optional_directive = directives.get('optional', None) output_source_directi...
python
def validate_vertex_field_directive_interactions(parent_location, vertex_field_name, directives): """Ensure that the specified vertex field directives are not mutually disallowed.""" fold_directive = directives.get('fold', None) optional_directive = directives.get('optional', None) output_source_directi...
[ "def", "validate_vertex_field_directive_interactions", "(", "parent_location", ",", "vertex_field_name", ",", "directives", ")", ":", "fold_directive", "=", "directives", ".", "get", "(", "'fold'", ",", "None", ")", "optional_directive", "=", "directives", ".", "get",...
Ensure that the specified vertex field directives are not mutually disallowed.
[ "Ensure", "that", "the", "specified", "vertex", "field", "directives", "are", "not", "mutually", "disallowed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L158-L188
233,043
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_field_directive_in_context
def validate_vertex_field_directive_in_context(parent_location, vertex_field_name, directives, context): """Ensure that the specified vertex field directives are allowed in the current context.""" fold_directive = directives.get('fold', None) optional_directive...
python
def validate_vertex_field_directive_in_context(parent_location, vertex_field_name, directives, context): """Ensure that the specified vertex field directives are allowed in the current context.""" fold_directive = directives.get('fold', None) optional_directive...
[ "def", "validate_vertex_field_directive_in_context", "(", "parent_location", ",", "vertex_field_name", ",", "directives", ",", "context", ")", ":", "fold_directive", "=", "directives", ".", "get", "(", "'fold'", ",", "None", ")", "optional_directive", "=", "directives...
Ensure that the specified vertex field directives are allowed in the current context.
[ "Ensure", "that", "the", "specified", "vertex", "field", "directives", "are", "allowed", "in", "the", "current", "context", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L191-L231
233,044
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_string
def _safe_match_string(value): """Sanitize and represent a string argument in MATCH.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attempting...
python
def _safe_match_string(value): """Sanitize and represent a string argument in MATCH.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attempting...
[ "def", "_safe_match_string", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "# should only happen in py3", "value", "=", "value", ".", "d...
Sanitize and represent a string argument in MATCH.
[ "Sanitize", "and", "represent", "a", "string", "argument", "in", "MATCH", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L17-L29
233,045
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_date_and_datetime
def _safe_match_date_and_datetime(graphql_type, expected_python_types, value): """Represent date and datetime objects as MATCH strings.""" # Python datetime.datetime is a subclass of datetime.date, # but in this case, the two are not interchangeable. # Rather than using isinstance, we will therefore che...
python
def _safe_match_date_and_datetime(graphql_type, expected_python_types, value): """Represent date and datetime objects as MATCH strings.""" # Python datetime.datetime is a subclass of datetime.date, # but in this case, the two are not interchangeable. # Rather than using isinstance, we will therefore che...
[ "def", "_safe_match_date_and_datetime", "(", "graphql_type", ",", "expected_python_types", ",", "value", ")", ":", "# Python datetime.datetime is a subclass of datetime.date,", "# but in this case, the two are not interchangeable.", "# Rather than using isinstance, we will therefore check fo...
Represent date and datetime objects as MATCH strings.
[ "Represent", "date", "and", "datetime", "objects", "as", "MATCH", "strings", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L32-L50
233,046
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_list
def _safe_match_list(inner_type, argument_value): """Represent the list of "inner_type" objects in MATCH form.""" stripped_type = strip_non_null_from_type(inner_type) if isinstance(stripped_type, GraphQLList): raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, ' ...
python
def _safe_match_list(inner_type, argument_value): """Represent the list of "inner_type" objects in MATCH form.""" stripped_type = strip_non_null_from_type(inner_type) if isinstance(stripped_type, GraphQLList): raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, ' ...
[ "def", "_safe_match_list", "(", "inner_type", ",", "argument_value", ")", ":", "stripped_type", "=", "strip_non_null_from_type", "(", "inner_type", ")", "if", "isinstance", "(", "stripped_type", ",", "GraphQLList", ")", ":", "raise", "GraphQLInvalidArgumentError", "("...
Represent the list of "inner_type" objects in MATCH form.
[ "Represent", "the", "list", "of", "inner_type", "objects", "in", "MATCH", "form", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L59-L75
233,047
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
insert_arguments_into_match_query
def insert_arguments_into_match_query(compilation_result, arguments): """Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for e...
python
def insert_arguments_into_match_query(compilation_result, arguments): """Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for e...
[ "def", "insert_arguments_into_match_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "MATCH_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", "com...
Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for every parameter the query expects. Returns: string, a MATCH query...
[ "Insert", "the", "arguments", "into", "the", "compiled", "MATCH", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L120-L142
233,048
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/metadata.py
SqlMetadata.get_table
def get_table(self, schema_type): """Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.""" table_name = schema_type.lower() if not self.has_table(table_name): raise exceptions.GraphQLCompilationError( 'No Table found in SQLAlchemy metadata for...
python
def get_table(self, schema_type): """Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.""" table_name = schema_type.lower() if not self.has_table(table_name): raise exceptions.GraphQLCompilationError( 'No Table found in SQLAlchemy metadata for...
[ "def", "get_table", "(", "self", ",", "schema_type", ")", ":", "table_name", "=", "schema_type", ".", "lower", "(", ")", "if", "not", "self", ".", "has_table", "(", "table_name", ")", ":", "raise", "exceptions", ".", "GraphQLCompilationError", "(", "'No Tabl...
Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.
[ "Retrieve", "a", "SQLAlchemy", "table", "based", "on", "the", "supplied", "GraphQL", "schema", "type", "name", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/metadata.py#L27-L34
233,049
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_per_location_tuple_to_step
def _per_location_tuple_to_step(ir_tuple): """Construct a MatchStep from a tuple of its constituent blocks.""" root_block = ir_tuple[0] if not isinstance(root_block, root_block_types): raise AssertionError(u'Unexpected root block type for MatchStep: ' u'{} {}'.format(roo...
python
def _per_location_tuple_to_step(ir_tuple): """Construct a MatchStep from a tuple of its constituent blocks.""" root_block = ir_tuple[0] if not isinstance(root_block, root_block_types): raise AssertionError(u'Unexpected root block type for MatchStep: ' u'{} {}'.format(roo...
[ "def", "_per_location_tuple_to_step", "(", "ir_tuple", ")", ":", "root_block", "=", "ir_tuple", "[", "0", "]", "if", "not", "isinstance", "(", "root_block", ",", "root_block_types", ")", ":", "raise", "AssertionError", "(", "u'Unexpected root block type for MatchStep:...
Construct a MatchStep from a tuple of its constituent blocks.
[ "Construct", "a", "MatchStep", "from", "a", "tuple", "of", "its", "constituent", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L39-L85
233,050
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_split_ir_into_match_steps
def _split_ir_into_match_steps(pruned_ir_blocks): """Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that ...
python
def _split_ir_into_match_steps(pruned_ir_blocks): """Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that ...
[ "def", "_split_ir_into_match_steps", "(", "pruned_ir_blocks", ")", ":", "output", "=", "[", "]", "current_tuple", "=", "None", "for", "block", "in", "pruned_ir_blocks", ":", "if", "isinstance", "(", "block", ",", "OutputSource", ")", ":", "# OutputSource blocks do...
Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that correspond to a single MATCH step.
[ "Split", "a", "list", "of", "IR", "blocks", "into", "per", "-", "location", "MATCH", "steps", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L88-L119
233,051
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_split_match_steps_into_match_traversals
def _split_match_steps_into_match_traversals(match_steps): """Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.""" output = [] current_list = None for step in match_steps: if isinstance(step.root_block, QueryRoot): if current_list is not None: ...
python
def _split_match_steps_into_match_traversals(match_steps): """Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.""" output = [] current_list = None for step in match_steps: if isinstance(step.root_block, QueryRoot): if current_list is not None: ...
[ "def", "_split_match_steps_into_match_traversals", "(", "match_steps", ")", ":", "output", "=", "[", "]", "current_list", "=", "None", "for", "step", "in", "match_steps", ":", "if", "isinstance", "(", "step", ".", "root_block", ",", "QueryRoot", ")", ":", "if"...
Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.
[ "Split", "a", "list", "of", "MatchSteps", "into", "multiple", "lists", "each", "denoting", "a", "single", "MATCH", "traversal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L122-L138
233,052
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
convert_to_match_query
def convert_to_match_query(ir_blocks): """Convert the list of IR blocks into a MatchQuery object, for easier manipulation.""" output_block = ir_blocks[-1] if not isinstance(output_block, ConstructResult): raise AssertionError(u'Expected last IR block to be ConstructResult, found: ' ...
python
def convert_to_match_query(ir_blocks): """Convert the list of IR blocks into a MatchQuery object, for easier manipulation.""" output_block = ir_blocks[-1] if not isinstance(output_block, ConstructResult): raise AssertionError(u'Expected last IR block to be ConstructResult, found: ' ...
[ "def", "convert_to_match_query", "(", "ir_blocks", ")", ":", "output_block", "=", "ir_blocks", "[", "-", "1", "]", "if", "not", "isinstance", "(", "output_block", ",", "ConstructResult", ")", ":", "raise", "AssertionError", "(", "u'Expected last IR block to be Const...
Convert the list of IR blocks into a MatchQuery object, for easier manipulation.
[ "Convert", "the", "list", "of", "IR", "blocks", "into", "a", "MatchQuery", "object", "for", "easier", "manipulation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L178-L211
233,053
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/sql_formatting.py
insert_arguments_into_sql_query
def insert_arguments_into_sql_query(compilation_result, arguments): """Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for ev...
python
def insert_arguments_into_sql_query(compilation_result, arguments): """Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for ev...
[ "def", "insert_arguments_into_sql_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "SQL_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", "compila...
Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for every parameter the query expects. Returns: SQLAlchemy Selectabl...
[ "Insert", "the", "arguments", "into", "the", "compiled", "SQL", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/sql_formatting.py#L10-L23
233,054
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
convert_coerce_type_to_instanceof_filter
def convert_coerce_type_to_instanceof_filter(coerce_type_block): """Create an "INSTANCEOF" Filter block from a CoerceType block.""" coerce_type_target = get_only_element_from_collection(coerce_type_block.target_class) # INSTANCEOF requires the target class to be passed in as a string, # so we make the ...
python
def convert_coerce_type_to_instanceof_filter(coerce_type_block): """Create an "INSTANCEOF" Filter block from a CoerceType block.""" coerce_type_target = get_only_element_from_collection(coerce_type_block.target_class) # INSTANCEOF requires the target class to be passed in as a string, # so we make the ...
[ "def", "convert_coerce_type_to_instanceof_filter", "(", "coerce_type_block", ")", ":", "coerce_type_target", "=", "get_only_element_from_collection", "(", "coerce_type_block", ".", "target_class", ")", "# INSTANCEOF requires the target class to be passed in as a string,", "# so we make...
Create an "INSTANCEOF" Filter block from a CoerceType block.
[ "Create", "an", "INSTANCEOF", "Filter", "block", "from", "a", "CoerceType", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L15-L24
233,055
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
convert_coerce_type_and_add_to_where_block
def convert_coerce_type_and_add_to_where_block(coerce_type_block, where_block): """Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.""" instanceof_filter = convert_coerce_type_to_instanceof_filter(coerce_type_block) if where_block: # There was already a Filter bl...
python
def convert_coerce_type_and_add_to_where_block(coerce_type_block, where_block): """Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.""" instanceof_filter = convert_coerce_type_to_instanceof_filter(coerce_type_block) if where_block: # There was already a Filter bl...
[ "def", "convert_coerce_type_and_add_to_where_block", "(", "coerce_type_block", ",", "where_block", ")", ":", "instanceof_filter", "=", "convert_coerce_type_to_instanceof_filter", "(", "coerce_type_block", ")", "if", "where_block", ":", "# There was already a Filter block -- we'll m...
Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.
[ "Create", "an", "INSTANCEOF", "Filter", "from", "a", "CoerceType", "adding", "to", "an", "existing", "Filter", "if", "any", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L27-L35
233,056
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
expression_list_to_conjunction
def expression_list_to_conjunction(expression_list): """Convert a list of expressions to an Expression that is the conjunction of all of them.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected `list`, Received {}.'.format(expression_list)) if len(expression_list) == 0: ...
python
def expression_list_to_conjunction(expression_list): """Convert a list of expressions to an Expression that is the conjunction of all of them.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected `list`, Received {}.'.format(expression_list)) if len(expression_list) == 0: ...
[ "def", "expression_list_to_conjunction", "(", "expression_list", ")", ":", "if", "not", "isinstance", "(", "expression_list", ",", "list", ")", ":", "raise", "AssertionError", "(", "u'Expected `list`, Received {}.'", ".", "format", "(", "expression_list", ")", ")", ...
Convert a list of expressions to an Expression that is the conjunction of all of them.
[ "Convert", "a", "list", "of", "expressions", "to", "an", "Expression", "that", "is", "the", "conjunction", "of", "all", "of", "them", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L38-L54
233,057
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
construct_where_filter_predicate
def construct_where_filter_predicate(query_metadata_table, simple_optional_root_info): """Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_l...
python
def construct_where_filter_predicate(query_metadata_table, simple_optional_root_info): """Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_l...
[ "def", "construct_where_filter_predicate", "(", "query_metadata_table", ",", "simple_optional_root_info", ")", ":", "inner_location_name_to_where_filter", "=", "{", "}", "for", "root_location", ",", "root_info_dict", "in", "six", ".", "iteritems", "(", "simple_optional_root...
Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_location` OR the `inner_location` is not defined. Return an Expression that evaluates to Tr...
[ "Return", "an", "Expression", "that", "is", "True", "if", "and", "only", "if", "each", "simple", "optional", "filter", "is", "True", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L192-L233
233,058
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
construct_optional_traversal_tree
def construct_optional_traversal_tree(complex_optional_roots, location_to_optional_roots): """Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand v...
python
def construct_optional_traversal_tree(complex_optional_roots, location_to_optional_roots): """Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand v...
[ "def", "construct_optional_traversal_tree", "(", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "tree", "=", "OptionalTraversalTree", "(", "complex_optional_roots", ")", "for", "optional_root_locations_stack", "in", "six", ".", "itervalues", "(", "lo...
Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand vertex fields location_to_optional_roots: dict mapping from location -> optional_roots wher...
[ "Return", "a", "tree", "of", "complex", "optional", "root", "locations", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L337-L355
233,059
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
BetweenClause.validate
def validate(self): """Validate that the Between Expression is correctly representable.""" if not isinstance(self.field, LocalField): raise TypeError(u'Expected LocalField field, got: {} {}'.format( type(self.field).__name__, self.field)) if not isinstance(self.lower...
python
def validate(self): """Validate that the Between Expression is correctly representable.""" if not isinstance(self.field, LocalField): raise TypeError(u'Expected LocalField field, got: {} {}'.format( type(self.field).__name__, self.field)) if not isinstance(self.lower...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "field", ",", "LocalField", ")", ":", "raise", "TypeError", "(", "u'Expected LocalField field, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "field", ")", ...
Validate that the Between Expression is correctly representable.
[ "Validate", "that", "the", "Between", "Expression", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L77-L89
233,060
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
BetweenClause.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this BetweenClause.""" template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})' return template.format( field_name=self.field.to_match(), lower_bound=self.lower_bound.to_match(), ...
python
def to_match(self): """Return a unicode object with the MATCH representation of this BetweenClause.""" template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})' return template.format( field_name=self.field.to_match(), lower_bound=self.lower_bound.to_match(), ...
[ "def", "to_match", "(", "self", ")", ":", "template", "=", "u'({field_name} BETWEEN {lower_bound} AND {upper_bound})'", "return", "template", ".", "format", "(", "field_name", "=", "self", ".", "field", ".", "to_match", "(", ")", ",", "lower_bound", "=", "self", ...
Return a unicode object with the MATCH representation of this BetweenClause.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "BetweenClause", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L101-L107
233,061
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
OptionalTraversalTree.insert
def insert(self, optional_root_locations_path): """Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of option...
python
def insert(self, optional_root_locations_path): """Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of option...
[ "def", "insert", "(", "self", ",", "optional_root_locations_path", ")", ":", "encountered_simple_optional", "=", "False", "parent_location", "=", "self", ".", "_root_location", "for", "optional_root_location", "in", "optional_root_locations_path", ":", "if", "encountered_...
Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of optional root Locations all except the last ...
[ "Insert", "a", "path", "of", "optional", "Locations", "into", "the", "tree", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L261-L285
233,062
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
emit_code_from_ir
def emit_code_from_ir(sql_query_tree, compiler_metadata): """Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query ...
python
def emit_code_from_ir(sql_query_tree, compiler_metadata): """Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query ...
[ "def", "emit_code_from_ir", "(", "sql_query_tree", ",", "compiler_metadata", ")", ":", "context", "=", "CompilationContext", "(", "query_path_to_selectable", "=", "dict", "(", ")", ",", "query_path_to_location_info", "=", "sql_query_tree", ".", "query_path_to_location_inf...
Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query
[ "Return", "a", "SQLAlchemy", "Query", "from", "a", "passed", "SqlQueryTree", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L39-L58
233,063
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_create_table_and_update_context
def _create_table_and_update_context(node, context): """Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly a...
python
def _create_table_and_update_context(node, context): """Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly a...
[ "def", "_create_table_and_update_context", "(", "node", ",", "context", ")", ":", "schema_type_name", "=", "sql_context_helpers", ".", "get_schema_type_name", "(", "node", ",", "context", ")", "table", "=", "context", ".", "compiler_metadata", ".", "get_table", "(",...
Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly aliased SQLAlchemy table.
[ "Create", "an", "aliased", "table", "for", "a", "SqlNode", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L75-L90
233,064
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_create_query
def _create_query(node, context): """Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query. """ visited_nodes = [node] output_colum...
python
def _create_query(node, context): """Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query. """ visited_nodes = [node] output_colum...
[ "def", "_create_query", "(", "node", ",", "context", ")", ":", "visited_nodes", "=", "[", "node", "]", "output_columns", "=", "_get_output_columns", "(", "visited_nodes", ",", "context", ")", "filters", "=", "_get_filters", "(", "visited_nodes", ",", "context", ...
Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query.
[ "Create", "a", "query", "from", "a", "SqlNode", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L93-L108
233,065
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_get_output_columns
def _get_output_columns(nodes, context): """Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to outp...
python
def _get_output_columns(nodes, context): """Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to outp...
[ "def", "_get_output_columns", "(", "nodes", ",", "context", ")", ":", "columns", "=", "[", "]", "for", "node", "in", "nodes", ":", "for", "sql_output", "in", "sql_context_helpers", ".", "get_outputs", "(", "node", ",", "context", ")", ":", "field_name", "=...
Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to output for this query.
[ "Get", "the", "output", "columns", "for", "a", "list", "of", "SqlNodes", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L111-L128
233,066
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_get_filters
def _get_filters(nodes, context): """Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions. """ f...
python
def _get_filters(nodes, context): """Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions. """ f...
[ "def", "_get_filters", "(", "nodes", ",", "context", ")", ":", "filters", "=", "[", "]", "for", "node", "in", "nodes", ":", "for", "filter_block", "in", "sql_context_helpers", ".", "get_filters", "(", "node", ",", "context", ")", ":", "filter_sql_expression"...
Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions.
[ "Get", "filters", "to", "apply", "to", "a", "list", "of", "SqlNodes", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L131-L146
233,067
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_filter_to_sql
def _transform_filter_to_sql(filter_block, node, context): """Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation ...
python
def _transform_filter_to_sql(filter_block, node, context): """Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation ...
[ "def", "_transform_filter_to_sql", "(", "filter_block", ",", "node", ",", "context", ")", ":", "expression", "=", "filter_block", ".", "predicate", "return", "_expression_to_sql", "(", "expression", ",", "node", ",", "context", ")" ]
Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation state and metadata. Returns: Expression, SQLAlchemy e...
[ "Transform", "a", "Filter", "block", "to", "its", "corresponding", "SQLAlchemy", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L149-L161
233,068
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_expression_to_sql
def _expression_to_sql(expression, node, context): """Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: Compilatio...
python
def _expression_to_sql(expression, node, context): """Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: Compilatio...
[ "def", "_expression_to_sql", "(", "expression", ",", "node", ",", "context", ")", ":", "_expression_transformers", "=", "{", "expressions", ".", "LocalField", ":", "_transform_local_field_to_expression", ",", "expressions", ".", "Variable", ":", "_transform_variable_to_...
Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Retu...
[ "Recursively", "transform", "a", "Filter", "block", "predicate", "to", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L164-L186
233,069
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_binary_composition_to_expression
def _transform_binary_composition_to_expression(expression, node, context): """Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compile...
python
def _transform_binary_composition_to_expression(expression, node, context): """Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compile...
[ "def", "_transform_binary_composition_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "if", "expression", ".", "operator", "not", "in", "constants", ".", "SUPPORTED_OPERATORS", ":", "raise", "NotImplementedError", "(", "u'Filter operation \"{}\...
Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compiler expression. node: SqlNode, the SqlNode the expression applies to. ...
[ "Transform", "a", "BinaryComposition", "compiler", "expression", "into", "a", "SQLAlchemy", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L189-L223
233,070
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_variable_to_expression
def _transform_variable_to_expression(expression, node, context): """Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: Compila...
python
def _transform_variable_to_expression(expression, node, context): """Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: Compila...
[ "def", "_transform_variable_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "variable_name", "=", "expression", ".", "variable_name", "if", "not", "variable_name", ".", "startswith", "(", "u'$'", ")", ":", "raise", "AssertionError", "(", ...
Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Returns: ...
[ "Transform", "a", "Variable", "compiler", "expression", "into", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L255-L270
233,071
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_local_field_to_expression
def _transform_local_field_to_expression(expression, node, context): """Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: ...
python
def _transform_local_field_to_expression(expression, node, context): """Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: ...
[ "def", "_transform_local_field_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "column_name", "=", "expression", ".", "field_name", "column", "=", "sql_context_helpers", ".", "get_column", "(", "column_name", ",", "node", ",", "context", ...
Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Returns: ...
[ "Transform", "a", "LocalField", "compiler", "expression", "into", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L273-L286
233,072
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
lower_context_field_existence
def lower_context_field_existence(ir_blocks, query_metadata_table): """Lower ContextFieldExistence expressions into lower-level expressions.""" def regular_visitor_fn(expression): """Expression visitor function that rewrites ContextFieldExistence expressions.""" if not isinstance(expression, Con...
python
def lower_context_field_existence(ir_blocks, query_metadata_table): """Lower ContextFieldExistence expressions into lower-level expressions.""" def regular_visitor_fn(expression): """Expression visitor function that rewrites ContextFieldExistence expressions.""" if not isinstance(expression, Con...
[ "def", "lower_context_field_existence", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "def", "regular_visitor_fn", "(", "expression", ")", ":", "\"\"\"Expression visitor function that rewrites ContextFieldExistence expressions.\"\"\"", "if", "not", "isinstance", "(", ...
Lower ContextFieldExistence expressions into lower-level expressions.
[ "Lower", "ContextFieldExistence", "expressions", "into", "lower", "-", "level", "expressions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L56-L95
233,073
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
optimize_boolean_expression_comparisons
def optimize_boolean_expression_comparisons(ir_blocks): """Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is re...
python
def optimize_boolean_expression_comparisons(ir_blocks): """Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is re...
[ "def", "optimize_boolean_expression_comparisons", "(", "ir_blocks", ")", ":", "operator_inverses", "=", "{", "u'='", ":", "u'!='", ",", "u'!='", ":", "u'='", ",", "}", "def", "visitor_fn", "(", "expression", ")", ":", "\"\"\"Expression visitor function that performs t...
Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is rewritten into: BinaryComposition('=', something, NullLit...
[ "Optimize", "comparisons", "of", "a", "boolean", "binary", "comparison", "expression", "against", "a", "boolean", "literal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L98-L171
233,074
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
extract_simple_optional_location_info
def extract_simple_optional_location_info( ir_blocks, complex_optional_roots, location_to_optional_roots): """Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_root...
python
def extract_simple_optional_location_info( ir_blocks, complex_optional_roots, location_to_optional_roots): """Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_root...
[ "def", "extract_simple_optional_location_info", "(", "ir_blocks", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "# Simple optional roots are a subset of location_to_optional_roots.values() (all optional roots)", "# We filter out the ones that are also present in c...
Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_roots: list of @optional locations (location immmediately preceding an @optional traverse) tha...
[ "Construct", "a", "map", "from", "simple", "optional", "locations", "to", "their", "inner", "location", "and", "traversed", "edge", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L283-L337
233,075
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
remove_end_optionals
def remove_end_optionals(ir_blocks): """Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.""" new_ir_blocks = [] for block in ir_blocks: if not isinstance(block, EndOptional): new_ir_blocks.append(block) return new_ir_blocks
python
def remove_end_optionals(ir_blocks): """Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.""" new_ir_blocks = [] for block in ir_blocks: if not isinstance(block, EndOptional): new_ir_blocks.append(block) return new_ir_blocks
[ "def", "remove_end_optionals", "(", "ir_blocks", ")", ":", "new_ir_blocks", "=", "[", "]", "for", "block", "in", "ir_blocks", ":", "if", "not", "isinstance", "(", "block", ",", "EndOptional", ")", ":", "new_ir_blocks", ".", "append", "(", "block", ")", "re...
Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.
[ "Return", "a", "list", "of", "IR", "blocks", "as", "a", "copy", "of", "the", "original", "with", "EndOptional", "blocks", "removed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L340-L346
233,076
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
OutputContextVertex.validate
def validate(self): """Validate that the OutputContextVertex is correctly representable.""" super(OutputContextVertex, self).validate() if self.location.field is not None: raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location))
python
def validate(self): """Validate that the OutputContextVertex is correctly representable.""" super(OutputContextVertex, self).validate() if self.location.field is not None: raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location))
[ "def", "validate", "(", "self", ")", ":", "super", "(", "OutputContextVertex", ",", "self", ")", ".", "validate", "(", ")", "if", "self", ".", "location", ".", "field", "is", "not", "None", ":", "raise", "ValueError", "(", "u'Expected location at a vertex, b...
Validate that the OutputContextVertex is correctly representable.
[ "Validate", "that", "the", "OutputContextVertex", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L35-L40
233,077
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
lower_has_substring_binary_compositions
def lower_has_substring_binary_compositions(ir_blocks): """Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.""" def visitor_fn(expression): """Rewrite BinaryComposition expressions with "has_substring" into representable form.""" # The implementation of "h...
python
def lower_has_substring_binary_compositions(ir_blocks): """Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.""" def visitor_fn(expression): """Rewrite BinaryComposition expressions with "has_substring" into representable form.""" # The implementation of "h...
[ "def", "lower_has_substring_binary_compositions", "(", "ir_blocks", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "\"\"\"Rewrite BinaryComposition expressions with \"has_substring\" into representable form.\"\"\"", "# The implementation of \"has_substring\" must use the LIKE ...
Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.
[ "Lower", "Filter", "blocks", "that", "use", "the", "has_substring", "operation", "into", "MATCH", "-", "representable", "form", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L96-L140
233,078
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
truncate_repeated_single_step_traversals
def truncate_repeated_single_step_traversals(match_query): """Truncate one-step traversals that overlap a previous traversal location.""" # Such traversals frequently happen as side-effects of the lowering process # of Backtrack blocks, and needlessly complicate the executed queries. new_match_traversal...
python
def truncate_repeated_single_step_traversals(match_query): """Truncate one-step traversals that overlap a previous traversal location.""" # Such traversals frequently happen as side-effects of the lowering process # of Backtrack blocks, and needlessly complicate the executed queries. new_match_traversal...
[ "def", "truncate_repeated_single_step_traversals", "(", "match_query", ")", ":", "# Such traversals frequently happen as side-effects of the lowering process", "# of Backtrack blocks, and needlessly complicate the executed queries.", "new_match_traversals", "=", "[", "]", "visited_locations"...
Truncate one-step traversals that overlap a previous traversal location.
[ "Truncate", "one", "-", "step", "traversals", "that", "overlap", "a", "previous", "traversal", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L143-L171
233,079
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
_flatten_location_translations
def _flatten_location_translations(location_translations): """If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency ...
python
def _flatten_location_translations(location_translations): """If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency ...
[ "def", "_flatten_location_translations", "(", "location_translations", ")", ":", "sources_to_process", "=", "set", "(", "six", ".", "iterkeys", "(", "location_translations", ")", ")", "def", "_update_translation", "(", "source", ")", ":", "\"\"\"Return the proper (fully...
If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency and simplicity of implementation.
[ "If", "location", "A", "translates", "to", "B", "and", "B", "to", "C", "then", "make", "A", "translate", "directly", "to", "C", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L224-L248
233,080
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
_translate_equivalent_locations
def _translate_equivalent_locations(match_query, location_translations): """Translate Location objects into their equivalent locations, based on the given dict.""" new_match_traversals = [] def visitor_fn(expression): """Expression visitor function used to rewrite expressions with updated Location ...
python
def _translate_equivalent_locations(match_query, location_translations): """Translate Location objects into their equivalent locations, based on the given dict.""" new_match_traversals = [] def visitor_fn(expression): """Expression visitor function used to rewrite expressions with updated Location ...
[ "def", "_translate_equivalent_locations", "(", "match_query", ",", "location_translations", ")", ":", "new_match_traversals", "=", "[", "]", "def", "visitor_fn", "(", "expression", ")", ":", "\"\"\"Expression visitor function used to rewrite expressions with updated Location data...
Translate Location objects into their equivalent locations, based on the given dict.
[ "Translate", "Location", "objects", "into", "their", "equivalent", "locations", "based", "on", "the", "given", "dict", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L251-L338
233,081
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
lower_folded_coerce_types_into_filter_blocks
def lower_folded_coerce_types_into_filter_blocks(folded_ir_blocks): """Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if isinstance(block, CoerceType): new_block = convert_coerce_type_to_...
python
def lower_folded_coerce_types_into_filter_blocks(folded_ir_blocks): """Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if isinstance(block, CoerceType): new_block = convert_coerce_type_to_...
[ "def", "lower_folded_coerce_types_into_filter_blocks", "(", "folded_ir_blocks", ")", ":", "new_folded_ir_blocks", "=", "[", "]", "for", "block", "in", "folded_ir_blocks", ":", "if", "isinstance", "(", "block", ",", "CoerceType", ")", ":", "new_block", "=", "convert_...
Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.
[ "Lower", "CoerceType", "blocks", "into", "INSTANCEOF", "Filter", "blocks", ".", "Indended", "for", "folded", "IR", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L341-L352
233,082
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
remove_backtrack_blocks_from_fold
def remove_backtrack_blocks_from_fold(folded_ir_blocks): """Return a list of IR blocks with all Backtrack blocks removed.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if not isinstance(block, Backtrack): new_folded_ir_blocks.append(block) return new_folded_ir_blocks
python
def remove_backtrack_blocks_from_fold(folded_ir_blocks): """Return a list of IR blocks with all Backtrack blocks removed.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if not isinstance(block, Backtrack): new_folded_ir_blocks.append(block) return new_folded_ir_blocks
[ "def", "remove_backtrack_blocks_from_fold", "(", "folded_ir_blocks", ")", ":", "new_folded_ir_blocks", "=", "[", "]", "for", "block", "in", "folded_ir_blocks", ":", "if", "not", "isinstance", "(", "block", ",", "Backtrack", ")", ":", "new_folded_ir_blocks", ".", "...
Return a list of IR blocks with all Backtrack blocks removed.
[ "Return", "a", "list", "of", "IR", "blocks", "with", "all", "Backtrack", "blocks", "removed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L355-L361
233,083
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
truncate_repeated_single_step_traversals_in_sub_queries
def truncate_repeated_single_step_traversals_in_sub_queries(compound_match_query): """For each sub-query, remove one-step traversals that overlap a previous traversal location.""" lowered_match_queries = [] for match_query in compound_match_query.match_queries: new_match_query = truncate_repeated_si...
python
def truncate_repeated_single_step_traversals_in_sub_queries(compound_match_query): """For each sub-query, remove one-step traversals that overlap a previous traversal location.""" lowered_match_queries = [] for match_query in compound_match_query.match_queries: new_match_query = truncate_repeated_si...
[ "def", "truncate_repeated_single_step_traversals_in_sub_queries", "(", "compound_match_query", ")", ":", "lowered_match_queries", "=", "[", "]", "for", "match_query", "in", "compound_match_query", ".", "match_queries", ":", "new_match_query", "=", "truncate_repeated_single_step...
For each sub-query, remove one-step traversals that overlap a previous traversal location.
[ "For", "each", "sub", "-", "query", "remove", "one", "-", "step", "traversals", "that", "overlap", "a", "previous", "traversal", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L364-L371
233,084
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_prune_traverse_using_omitted_locations
def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations, complex_optional_roots, location_to_optional_roots): """Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of comple...
python
def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations, complex_optional_roots, location_to_optional_roots): """Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of comple...
[ "def", "_prune_traverse_using_omitted_locations", "(", "match_traversal", ",", "omitted_locations", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "new_match_traversal", "=", "[", "]", "for", "step", "in", "match_traversal", ":", "new_step", "...
Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of complex_optional_roots, return a new match traversal removing all MatchStep objects that are within any omitted location. Args: match_traversal: list of MatchStep objects to...
[ "Return", "a", "prefix", "of", "the", "given", "traverse", "excluding", "any", "blocks", "after", "an", "omitted", "optional", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L18-L82
233,085
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
convert_optional_traversals_to_compound_match_query
def convert_optional_traversals_to_compound_match_query( match_query, complex_optional_roots, location_to_optional_roots): """Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different Mat...
python
def convert_optional_traversals_to_compound_match_query( match_query, complex_optional_roots, location_to_optional_roots): """Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different Mat...
[ "def", "convert_optional_traversals_to_compound_match_query", "(", "match_query", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "tree", "=", "construct_optional_traversal_tree", "(", "complex_optional_roots", ",", "location_to_optional_roots", ")", "...
Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different MatchQuery objects: one for each possible subset of optional edges that can be followed. For each edge `e` in a subset of optional ed...
[ "Return", "2^n", "distinct", "MatchQuery", "objects", "in", "a", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L85-L151
233,086
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_get_present_locations
def _get_present_locations(match_traversals): """Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be i...
python
def _get_present_locations(match_traversals): """Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be i...
[ "def", "_get_present_locations", "(", "match_traversals", ")", ":", "present_locations", "=", "set", "(", ")", "present_non_optional_locations", "=", "set", "(", ")", "for", "match_traversal", "in", "match_traversals", ":", "for", "step", "in", "match_traversal", ":...
Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be included in the returned `present_locations`. All ...
[ "Return", "the", "set", "of", "locations", "and", "non", "-", "optional", "locations", "present", "in", "the", "given", "match", "traversals", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L154-L190
233,087
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
prune_non_existent_outputs
def prune_non_existent_outputs(compound_match_query): """Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned...
python
def prune_non_existent_outputs(compound_match_query): """Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned...
[ "def", "prune_non_existent_outputs", "(", "compound_match_query", ")", ":", "if", "len", "(", "compound_match_query", ".", "match_queries", ")", "==", "1", ":", "return", "compound_match_query", "elif", "len", "(", "compound_match_query", ".", "match_queries", ")", ...
Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned away) from each corresponding ConstructResult block. ...
[ "Remove", "non", "-", "existent", "outputs", "from", "each", "MatchQuery", "in", "the", "given", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L193-L266
233,088
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_construct_location_to_filter_list
def _construct_location_to_filter_list(match_query): """Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of ...
python
def _construct_location_to_filter_list(match_query): """Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of ...
[ "def", "_construct_location_to_filter_list", "(", "match_query", ")", ":", "# For each location, all filters for that location should be applied at the first instance.", "# This function collects a list of all filters corresponding to each location", "# present in the given MatchQuery.", "location...
Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of Filter objects applied at that location
[ "Return", "a", "dict", "mapping", "location", "-", ">", "list", "of", "filters", "applied", "at", "that", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L269-L291
233,089
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_filter_list_to_conjunction_expression
def _filter_list_to_conjunction_expression(filter_list): """Convert a list of filters to an Expression that is the conjunction of all of them.""" if not isinstance(filter_list, list): raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list)) if any((not isinstance(filter_block, Fil...
python
def _filter_list_to_conjunction_expression(filter_list): """Convert a list of filters to an Expression that is the conjunction of all of them.""" if not isinstance(filter_list, list): raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list)) if any((not isinstance(filter_block, Fil...
[ "def", "_filter_list_to_conjunction_expression", "(", "filter_list", ")", ":", "if", "not", "isinstance", "(", "filter_list", ",", "list", ")", ":", "raise", "AssertionError", "(", "u'Expected `list`, Received: {}.'", ".", "format", "(", "filter_list", ")", ")", "if...
Convert a list of filters to an Expression that is the conjunction of all of them.
[ "Convert", "a", "list", "of", "filters", "to", "an", "Expression", "that", "is", "the", "conjunction", "of", "all", "of", "them", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L294-L302
233,090
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_apply_filters_to_first_location_occurrence
def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters, already_filtered_locations): """Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, con...
python
def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters, already_filtered_locations): """Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, con...
[ "def", "_apply_filters_to_first_location_occurrence", "(", "match_traversal", ",", "location_to_filters", ",", "already_filtered_locations", ")", ":", "new_match_traversal", "=", "[", "]", "newly_filtered_locations", "=", "set", "(", ")", "for", "match_step", "in", "match...
Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, construct a conjunction of all filters applied to that location, and apply the resulting Filter to the first instance of the location. Args: match_traversal...
[ "Apply", "all", "filters", "for", "a", "specific", "location", "into", "its", "first", "occurrence", "in", "a", "given", "traversal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L305-L355
233,091
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
collect_filters_to_first_location_occurrence
def collect_filters_to_first_location_occurrence(compound_match_query): """Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their ...
python
def collect_filters_to_first_location_occurrence(compound_match_query): """Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their ...
[ "def", "collect_filters_to_first_location_occurrence", "(", "compound_match_query", ")", ":", "new_match_queries", "=", "[", "]", "# Each MatchQuery has a different set of locations, and associated Filters.", "# Hence, each of them is processed independently.", "for", "match_query", "in"...
Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their first occurence. OrientDB does not resolve this behavior correctly. Therefo...
[ "Collect", "all", "filters", "for", "a", "particular", "location", "to", "the", "first", "instance", "of", "the", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L358-L402
233,092
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_update_context_field_binary_composition
def _update_context_field_binary_composition(present_locations, expression): """Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least on...
python
def _update_context_field_binary_composition(present_locations, expression): """Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least on...
[ "def", "_update_context_field_binary_composition", "(", "present_locations", ",", "expression", ")", ":", "if", "not", "any", "(", "(", "isinstance", "(", "expression", ".", "left", ",", "ContextField", ")", ",", "isinstance", "(", "expression", ".", "right", ",...
Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least one ContextField operand Returns: TrueLiteral iff either ContextField ope...
[ "Lower", "BinaryCompositions", "involving", "non", "-", "existent", "ContextFields", "to", "True", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L405-L433
233,093
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_simplify_non_context_field_binary_composition
def _simplify_non_context_field_binary_composition(expression): """Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conju...
python
def _simplify_non_context_field_binary_composition(expression): """Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conju...
[ "def", "_simplify_non_context_field_binary_composition", "(", "expression", ")", ":", "if", "any", "(", "(", "isinstance", "(", "expression", ".", "left", ",", "ContextField", ")", ",", "isinstance", "(", "expression", ".", "right", ",", "ContextField", ")", ")"...
Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conjunction and one of it's operands is a TrueLiteral, and t...
[ "Return", "a", "simplified", "BinaryComposition", "if", "either", "operand", "is", "a", "TrueLiteral", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L436-L465
233,094
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_update_context_field_expression
def _update_context_field_expression(present_locations, expression): """Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.""" no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable) if isinstance(expression, BinaryComposition): if isi...
python
def _update_context_field_expression(present_locations, expression): """Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.""" no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable) if isinstance(expression, BinaryComposition): if isi...
[ "def", "_update_context_field_expression", "(", "present_locations", ",", "expression", ")", ":", "no_op_blocks", "=", "(", "ContextField", ",", "Literal", ",", "LocalField", ",", "UnaryTransformation", ",", "Variable", ")", "if", "isinstance", "(", "expression", ",...
Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.
[ "Lower", "Expressions", "involving", "non", "-", "existent", "ContextFields", "to", "TrueLiteral", "and", "simplify", "result", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L484-L508
233,095
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_lower_non_existent_context_field_filters
def _lower_non_existent_context_field_filters(match_traversals, visitor_fn): """Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a Tr...
python
def _lower_non_existent_context_field_filters(match_traversals, visitor_fn): """Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a Tr...
[ "def", "_lower_non_existent_context_field_filters", "(", "match_traversals", ",", "visitor_fn", ")", ":", "new_match_traversals", "=", "[", "]", "for", "match_traversal", "in", "match_traversals", ":", "new_match_traversal", "=", "[", "]", "for", "step", "in", "match_...
Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a TrueLiteral, are lowered appropriately based on the present operator (u'||' and u'...
[ "Return", "new", "match", "traversals", "lowering", "filters", "involving", "non", "-", "existent", "ContextFields", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L511-L544
233,096
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
lower_context_field_expressions
def lower_context_field_expressions(compound_match_query): """Lower Expressons involving non-existent ContextFields.""" if len(compound_match_query.match_queries) == 0: raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.' .format(compound_match_...
python
def lower_context_field_expressions(compound_match_query): """Lower Expressons involving non-existent ContextFields.""" if len(compound_match_query.match_queries) == 0: raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.' .format(compound_match_...
[ "def", "lower_context_field_expressions", "(", "compound_match_query", ")", ":", "if", "len", "(", "compound_match_query", ".", "match_queries", ")", "==", "0", ":", "raise", "AssertionError", "(", "u'Received CompoundMatchQuery {} with no MatchQuery objects.'", ".", "forma...
Lower Expressons involving non-existent ContextFields.
[ "Lower", "Expressons", "involving", "non", "-", "existent", "ContextFields", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L547-L574
233,097
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_edges_do_not_have_extra_links
def _validate_edges_do_not_have_extra_links(class_name, properties): """Validate that edges do not have properties of Link type that aren't the edge endpoints.""" for property_name, property_descriptor in six.iteritems(properties): if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT...
python
def _validate_edges_do_not_have_extra_links(class_name, properties): """Validate that edges do not have properties of Link type that aren't the edge endpoints.""" for property_name, property_descriptor in six.iteritems(properties): if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT...
[ "def", "_validate_edges_do_not_have_extra_links", "(", "class_name", ",", "properties", ")", ":", "for", "property_name", ",", "property_descriptor", "in", "six", ".", "iteritems", "(", "properties", ")", ":", "if", "property_name", "in", "{", "EDGE_SOURCE_PROPERTY_NA...
Validate that edges do not have properties of Link type that aren't the edge endpoints.
[ "Validate", "that", "edges", "do", "not", "have", "properties", "of", "Link", "type", "that", "aren", "t", "the", "edge", "endpoints", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L44-L53
233,098
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_property_names
def _validate_property_names(class_name, properties): """Validate that properties do not have names that may cause problems in the GraphQL schema.""" for property_name in properties: if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES): raise IllegalSchemaStateErr...
python
def _validate_property_names(class_name, properties): """Validate that properties do not have names that may cause problems in the GraphQL schema.""" for property_name in properties: if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES): raise IllegalSchemaStateErr...
[ "def", "_validate_property_names", "(", "class_name", ",", "properties", ")", ":", "for", "property_name", "in", "properties", ":", "if", "not", "property_name", "or", "property_name", ".", "startswith", "(", "ILLEGAL_PROPERTY_NAME_PREFIXES", ")", ":", "raise", "Ill...
Validate that properties do not have names that may cause problems in the GraphQL schema.
[ "Validate", "that", "properties", "do", "not", "have", "names", "that", "may", "cause", "problems", "in", "the", "GraphQL", "schema", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L56-L61
233,099
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_collections_have_default_values
def _validate_collections_have_default_values(class_name, property_name, property_descriptor): """Validate that if the property is of collection type, it has a specified default value.""" # We don't want properties of collection type having "null" values, since that may cause # unexpected errors during Grap...
python
def _validate_collections_have_default_values(class_name, property_name, property_descriptor): """Validate that if the property is of collection type, it has a specified default value.""" # We don't want properties of collection type having "null" values, since that may cause # unexpected errors during Grap...
[ "def", "_validate_collections_have_default_values", "(", "class_name", ",", "property_name", ",", "property_descriptor", ")", ":", "# We don't want properties of collection type having \"null\" values, since that may cause", "# unexpected errors during GraphQL query execution and other operati...
Validate that if the property is of collection type, it has a specified default value.
[ "Validate", "that", "if", "the", "property", "is", "of", "collection", "type", "it", "has", "a", "specified", "default", "value", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L64-L71