Return the FROM clause, converted the SOQL dialect.

        It should be only the name of base object, even in parent-to-child and
        child-to-parent relationships queries.
16419
def get_from_clause(self):
        
        self.query_topology()
        root_table = self.soql_trans[self.root_alias]
        return [root_table], []
1160065
static <S> String translate(CriteriaQuery criteriaQuery)
    {
        QueryBuilder builder = new CriteriaQueryTranslator.QueryBuilder();

        // validate if criteria query is valid

        /**
         * select, from clause is mandatory
         * 
         * multiple from clause not support where clause is optional
         * 
         */

        Selection<S> select = criteriaQuery.getSelection();

        if (select != null)
        {
            builder.appendSelectClause();

        }

        if (select.getClass().isAssignableFrom(DefaultCompoundSelection.class)
                && ((CompoundSelection) select).isCompoundSelection())
        {
            List<Selection<?>> selections = ((CompoundSelection) select).getCompoundSelectionItems();
            builder.appendMultiSelect(selections);
        }
        else if (select instanceof AggregateExpression)
        {
            builder.appendAggregate(((AggregateExpression) select).getAggregation());
        }
        else
        {
            String alias = select.getAlias();

            if (!StringUtils.isEmpty(alias))
            {
                builder.appendAlias(alias);
            }

            Attribute attribute = ((DefaultPath) select).getAttribute();

            if (attribute != null)
            {
                builder.appendAttribute(attribute);
            }
        }
        Class<? extends S> clazzType = select.getJavaType();

        Set<Root<?>> roots = criteriaQuery.getRoots();

        Root<?> from = roots.iterator().next();

        Class entityClazz = from.getJavaType();

        builder.appendFromClause();

        // select.alias(paramString)
        builder.appendFrom(entityClazz);
        builder.appendAlias(from.getAlias() != null ? from.getAlias() : select.getAlias());
        Predicate where = criteriaQuery.getRestriction(); // this could be null.
        if (where != null)
        {
            builder.appendWhereClause();
            List<Expression<Boolean>> expressions = where.getExpressions();
            for (Expression expr : expressions)
            {
                builder.appendWhere(expr, from.getAlias());
            }

        }

        List<Order> orderings = criteriaQuery.getOrderList();

        if (orderings != null && !orderings.isEmpty())
        {
            builder.appendOrderClause(where == null);
            String alias = from.getAlias() != null ? from.getAlias() : select.getAlias();
            builder.appendMultiOrdering(orderings, alias);
        }
        return builder.getQuery();

        // check that roots has to be one. multiple clause not yet supported

    }
1157345
def fromlineno(self):
        
        lineno = super(Arguments, self).fromlineno
        return max(lineno, self.parent.fromlineno or 0)
1217268
def from_dict(cls, d):
        """"""
        relationship = super(cls, cls).from_dict(d)
        if relationship.name is not None:
            relationship.name = Name.from_dict(relationship.name)
        return relationship
1020297
def from_taxdb(cls, con, root=None):
        
        cursor = con.cursor()
        if root is None:
            cursor.execute(
                "SELECT tax_id, rank FROM nodes WHERE tax_id = parent_id")
        else:
            cursor.execute(
                "SELECT tax_id, rank FROM nodes WHERE tax_id = ?", [root])

        tax_id, rank = cursor.fetchone()
        root = cls(rank=rank, tax_id=tax_id)

        def add_lineage(parent):
            cursor.execute("""SELECT tax_id, rank, tax_name
                    FROM nodes INNER JOIN names USING (tax_id)
                    WHERE parent_id = :1 and tax_id <> :1
                        AND names.is_primary = 1
                    """, [parent.tax_id])
            for tax_id, rank, name in cursor:
                node = cls(rank=rank, tax_id=tax_id, name=name)
                parent.add_child(node)
            for child in parent.children:
                add_lineage(child)

        add_lineage(root)
        return root
39416
def get_tree(cls, *condition, **kwargs):
        
        parent_field = kwargs.pop('parent_field', 'parent')
        parent = kwargs.pop('parent', None)
        parent_order_by = kwargs.pop('parent_order_by', None)
        current = kwargs.pop('current', None)
        order_by = kwargs.pop('order_by', None)
        id_field = kwargs.pop('id_field', 'id')
        mode = kwargs.pop('mode', 'wide')
        if mode not in ('wide', 'deep'):
            raise Exception("mode parameter should be 'wide' or 'deep', but '{}' found.".format(mode))

        def _f(parent):
            query = cls.filter(cls.c[parent_field]==parent, *condition)
            if order_by is not None:
                query.order_by(order_by)
            for row in query:
                if mode == 'wide':
                    yield row
                for _row in _f(getattr(row, id_field)):
                    yield _row
                if mode == 'deep':
                    yield row

        if current:
            query = cls.filter(cls.c[id_field]==current)
        else:
            if is_condition(parent):
                query = cls.filter(parent)
            else:
                query = cls.filter(cls.c[parent_field]==parent)
        if parent_order_by is not None:
            query.order_by(parent_order_by)
        for row in query:
            if mode == 'wide':
                yield row
            for r in _f(getattr(row, id_field)):
                yield r
            if mode == 'deep':
                yield row
789923
def query( self ):
        
        # create the query compound
        if ( self.childCount() ):
            q = Q()
            operator = 'and'
            for i in range(self.childCount()):
                item = self.child(i)
                if ( isinstance(item, XQueryItem) ):
                    if ( operator == 'and' ):
                        q &= item.query()
                    else:
                        q |= item.query()
                else:
                    operator = nativestring(item.text(0))
            return q
        
        # create the query for this individual item
        else:
            q = Q(self.columnName())
            q.setOperatorType(self.operatorType())
            q.setValue(self.value())
            return q
1053155
def get_relation_count_query(self, query, parent):
        
        query.select(QueryExpression("COUNT(*)"))

        key = self.wrap(self.get_qualified_parent_key_name())

        return query.where(self.get_has_compare_key(), "=", QueryExpression(key))
287139
public Query from(final Expression... fromColumns) {
        if (fromColumns == null) {
            return this;
        }

        return from(Arrays.asList(fromColumns));
    }
658252
def _get_child_relation(self, child_pid):
        """"""
        return PIDRelation.query.filter_by(
            parent=self._resolved_pid,
            child=child_pid,
            relation_type=self.relation_type.id).one()
1315598
def to_subquery
      collection = model.all(merge(:fields => model_key))
      Conditions::Operation.new(:and, Conditions::Comparison.new(:in, self_relationship, collection))
    end
990766
def query(self, query):
    '''
    '''
    self.logger.info('%s: query %s' % (self, query))
    return super(LoggingDatastore, self).query(query)
423000
private void convertToTermsQuery(FilterJoinNode node) {
    Map<String, Object> parent = node.getParentSourceMap();
    FilterJoinTerms terms = node.getTerms();
    BytesRef bytes = terms.getEncodedTerms();

    // Remove the filter join from the parent
    parent.remove(FilterJoinBuilder.NAME);

    // Create the nested object for the parameters of the field data terms query
    Map<String, Object> queryParams = new HashMap<>();
    queryParams.put("value", bytes.bytes);
    // use the hash of the filter join source map as cache key - see #170
    queryParams.put("_cache_key", node.getCacheId());

    // Create the nested object for the field
    Map<String, Object> field = new HashMap<>();
    field.put(node.getField(), queryParams);

    // Create the nested object for the field data terms query
    Map<String, Object> termsQuery = new HashMap<>();
    // If bytes terms encoding is used, we switch to the terms enum based terms query
    if (node.getTermsEncoding().equals(TermsByQueryRequest.TermsEncoding.BYTES)) {
      termsQuery.put(TermsEnumTermsQueryParser.NAME, field);
    }
    else {
      termsQuery.put(FieldDataTermsQueryParser.NAME, field);
    }

    // Create the object for the constant score query
    Map<String, Object> constantScoreQueryParams = new HashMap<>();
    constantScoreQueryParams.put("filter", termsQuery);

    // Add the constant score query to the parent
    parent.put(ConstantScoreQueryParser.NAME, constantScoreQueryParams);
    node.setState(FilterJoinNode.State.CONVERTED);
    this.blockingQueue.poll();
  }
1277380
def from_where(cls, where):
        
        if where.conjunction:
            return Conjunction.from_clause(where)
        else:
            return cls.from_clause(where[0])
238842
def get_where_clause_from_dict(dictionary, join_operator='AND'):
        
        CoyoteDb.escape_dictionary(dictionary)
        clause = join_operator.join(
            (' {k} is {v} ' if str(v).lower() == 'null' else ' {k} = {v} ').format(k=k, v=v)  # IS should be the operator for null values
            for k, v in dictionary.iteritems())
        return clause
798485
def get_tree(cls, parent=None):
        
        cls = get_result_class(cls)

        if parent is None:
            # return the entire tree
            return cls.objects.all()
        if parent.is_leaf():
            return cls.objects.filter(pk=parent.pk)
        return cls.objects.filter(
            path__startswith=parent.path,
            depth__gte=parent.depth
        ).order_by(
            'path'
        )
224805
def query(self, parents=None):
        
        # TODO: benchmark single-query strategy
        q = Select([])
        q = self.project(q, parent=True)
        q = self.filter(q, parents=parents)

        if self.parent is None:
            subq = Select([self.var])
            subq = self.filter(subq, parents=parents)
            subq = subq.offset(self.node.offset)
            subq = subq.limit(self.node.limit)
            subq = subq.distinct()
            # TODO: sorting.
            subq = subq.order_by(desc(self.var))
            q = q.where(subq)

        # if hasattr(self.context, 'identifier'):
        #     q._where = graph(self.context.identifier, q._where)
        log.debug("Compiled query: %r", q.compile())
        return q