zetasql/resolved_ast/gen_resolved_ast.py
def TraverseToRoot(node):
      """Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      """
      node.setdefault('num_descendant_leaf_types', 0)
      node['num_descendant_leaf_types'] += 1

      for field in node['fields']:
        field_type = field['ctype']
        if field_type in self.node_map:
          field_node = self._GetNodeByName(field_type)
          field['proto_type'] = field_node['proto_field_type']

      parent_name = node['parent']
      if parent_name != ROOT_NODE_NAME:
        parent_node = self._GetNodeByName(parent_name)
        TraverseToRoot(parent_node)
        parent_subclass_list = parent_node['subclasses']
      else:
        parent_subclass_list = self.root_child_nodes

      # Note: this comparison is by value, so the transitive closure of <node>'s
      # entries cannot contain <node>.
      if node not in parent_subclass_list:
        parent_subclass_list.append(node)
Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      
Count the number of leaf nodes existing as descendents of each node.
Traverses upwards from each leaf, incrementing a counter.
Count the number of leaf nodes existing as descendents of each node . Traverses upwards from each leaf incrementing a counter .
def TraverseToRoot(node):
      node.setdefault('num_descendant_leaf_types', 0)
      node['num_descendant_leaf_types'] += 1
      for field in node['fields']:
        field_type = field['ctype']
        if field_type in self.node_map:
          field_node = self._GetNodeByName(field_type)
          field['proto_type'] = field_node['proto_field_type']
      parent_name = node['parent']
      if parent_name != ROOT_NODE_NAME:
        parent_node = self._GetNodeByName(parent_name)
        TraverseToRoot(parent_node)
        parent_subclass_list = parent_node['subclasses']
      else:
        parent_subclass_list = self.root_child_nodes
      if node not in parent_subclass_list:
        parent_subclass_list.append(node)
def TraverseToRoot ( node ) : node . setdefault ( 'num_descendant_leaf_types' , 0 ) node [ 'num_descendant_leaf_types' ] += 1 for field in node [ 'fields' ] : field_type = field [ 'ctype' ] if field_type in self . node_map : field_node = self . _GetNodeByName ( field_type ) field [ 'proto_type' ] = field_node [ 'proto_field_type' ] parent_name = node [ 'parent' ] if parent_name != ROOT_NODE_NAME : parent_node = self . _GetNodeByName ( parent_name ) TraverseToRoot ( parent_node ) parent_subclass_list = parent_node [ 'subclasses' ] else : parent_subclass_list = self . root_child_nodes if node not in parent_subclass_list : parent_subclass_list . append ( node )
Count the number of leaf nodes existing as descendents of each node.
Count the number of leaf nodes existing as descendents of each node .
"""Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      """ # Note: this comparison is by value, so the transitive closure of <node>'s # entries cannot contain <node>.
node
Node to count descendents of.
Node to count descendents of .