docs: def _build_query(self, table, tree, visitor):
          """ Build a scan/query from a statement """
          kwargs = {}
          index = None
          if tree.using:
              index_name = kwargs["index"] = tree.using[1]
              index = table.get_index(index_name)
          if tree.where:
              constraints = ConstraintExpression.from_where(tree.where)
              possible_hash = constraints.possible_hash_fields()
              possible_range = constraints.possible_range_fields()
              if index is None:
                  # See if we can find an index to query on
                  indexes = table.get_matching_indexes(possible_hash, possible_range)
                  if not indexes:
                      action = "scan"
                      kwargs["filter"] = constraints.build(visitor)
                      kwargs["expr_values"] = visitor.expression_values
                      kwargs["alias"] = visitor.attribute_names
                  elif len(indexes) == 1:
                      index = indexes[0]
                      action = "query"
                      add_query_kwargs(kwargs, visitor, constraints, index)
                  else:
                      names = ", ".join([index.name for index in indexes])
                      raise SyntaxError(
                          "No index specified with USING <index>, "
                          "but multiple possibilities for query: "
                          "%s" % names
                      )
              else:
                  if index.hash_key in possible_hash:
                      action = "query"
                      add_query_kwargs(kwargs, visitor, constraints, index)
                  else:
                      action = "scan"
                      if not index.scannable:
                          raise SyntaxError("Cannot scan local index %r" % index_name)
                      kwargs["filter"] = constraints.build(visitor)
                      kwargs["expr_values"] = visitor.expression_values
                      kwargs["alias"] = visitor.attribute_names
          else:
              action = "scan"
          return [action, kwargs, index]