@param TokenSequencerInterface $query

@throws InterpretationException
@return CompiledQuery
972185
public function interpret(TokenSequencerInterface $query)
    {
        if (empty($this->metadataProvider)) {
            throw new InterpretationException("Cannot interpret any queries without an Entity Metadata Provider");
        }

        $this->tokenParser->parseTokenSequence($query);

        // select interpreter
        $selectedInterpreter = null;
        $queryType = $query->getType();
        foreach ($this->queryTypeInterpreters as $interpreter) {
            /** @var AbstractSqlQueryTypeInterpreter $interpreter */
            if ($interpreter->supportedQueryType() == $queryType) {
                $selectedInterpreter = $interpreter;
                break;
            }
        }
        if (empty($selectedInterpreter)) {
            throw new InterpretationException("Cannot interpret query. The query type '$queryType' is not supported by any of the installed QueryTypeInterpreters");
        }

        $compiledQuery = new CompiledQuery();
        $compiledQuery->setQuery($selectedInterpreter->interpretQuery($query));
        $compiledQuery->setArguments($selectedInterpreter->getValues());
        $compiledQuery->setPrimaryKeySequence($selectedInterpreter->getPrimaryKeySequence());

        return $compiledQuery;
    }
623702
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_TABLE_STATUS) {
            return null;
        }

        $likeExpr = $query->getLikeExpression();
        $tablet = $this->tablet->getTablet();
        $command = new GetSchema($tablet->getAlias());
        /* @var $vtCtldResult GetSchemaResult */
        $vtCtldResult = $this->client->executeCommand($command);

        return new TableStatus($vtCtldResult, $likeExpr);
    }
15762
@Override
    protected Query parseQuery( TokenStream tokens,
                                TypeSystem typeSystem ) {
        Query query = super.parseQuery(tokens, typeSystem);
        // See if we have to rewrite the JCR-SQL-style join ...
        if (query.source() instanceof JoinableSources) {
            JoinableSources joinableSources = (JoinableSources)query.source();
            // Rewrite the joins ...
            Source newSource = rewrite(joinableSources);
            query = new Query(newSource, query.constraint(), query.orderings(), query.columns(), query.getLimits(),
                              query.isDistinct());
        }
        return query;
    }
1107298
public function explainAction($token, $connectionName, $query)
    {
        /** @var Profiler $profiler */
        $profiler = $this->container->get('profiler');
        $profiler->disable();

        $profile = $profiler->loadProfile($token);
        $queries = $profile->getCollector('db')->getQueries();

        if (! isset($queries[$connectionName][$query])) {
            return new Response('This query does not exist.');
        }

        $query = $queries[$connectionName][$query];
        if (! $query['explainable']) {
            return new Response('This query cannot be explained.');
        }

        /** @var Connection $connection */
        $connection = $this->container->get('doctrine')->getConnection($connectionName);
        try {
            if ($connection->getDatabasePlatform() instanceof SQLServerPlatform) {
                $results = $this->explainSQLServerPlatform($connection, $query);
            } else {
                $results = $this->explainOtherPlatform($connection, $query);
            }
        } catch (Exception $e) {
            return new Response('This query cannot be explained.');
        }

        return new Response($this->container->get('twig')->render('@Doctrine/Collector/explain.html.twig', [
            'data' => $results,
            'query' => $query,
        ]));
    }
751145
public function compileSelect(Builder $query)
	{
		$components = $this->compileComponents($query);

		// If an offset is present on the query, we will need to wrap the query in
		// a big "ANSI" offset syntax block. This is very nasty compared to the
		// other database systems but is necessary for implementing features.
		if ($query->offset > 0)
		{
			return $this->compileAnsiOffset($query, $components);
		}

		return $this->concatenate($components);
	}
814833
public function createCode(TokenInterface $code): TokenInterface
    {
        try {
            $now    = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $schema = $this->getDatabaseSchema();
            $values = [
                $schema->getTokensClientIdentityColumn() => $code->getClientIdentifier(),
                $schema->getTokensUserIdentityColumn()   => $code->getUserIdentifier(),
                $schema->getTokensCodeColumn()           => $code->getCode(),
                $schema->getTokensIsScopeModified()      => $code->isScopeModified(),
                $schema->getTokensCodeCreatedAtColumn()  => $now,
            ];

            $tokenIdentifier = null;
            if (empty($scopeIdentifiers = $code->getScopeIdentifiers()) === false) {
                $this->inTransaction(function () use ($values, $scopeIdentifiers, &$tokenIdentifier) {
                    $this->createResource($values);
                    $tokenIdentifier = $this->getLastInsertId();
                    $this->bindScopeIdentifiers($tokenIdentifier, $scopeIdentifiers);
                });
            } else {
                $this->createResource($values);
                $tokenIdentifier = $this->getLastInsertId();
            }

            $code->setIdentifier($tokenIdentifier)->setCodeCreatedAt($now);

            return $code;
        } catch (RepositoryException $exception) {
            $message = 'Token code creation failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
268997
public function buildStatement(Query $query) {
        $type = $query->getType();
        $method = 'build' . ucfirst($type);
        $dialect = $this->getDialect();

        if (!method_exists($dialect, $method)) {
            throw new UnsupportedQueryStatementException(sprintf('Query statement %s does not exist or has not been implemented', $type));
        }

        return $this->getConnection()->prepare(call_user_func([$dialect, $method], $query));
    }
650272
public static Query create(String query) 
		throws QueryParserException
	{
		QueryTokenizer tokenizer = new QueryTokenizerImpl();
		QueryParser parser = new QueryParserImpl();

		return parser.parse(tokenizer.tokenize(query));
	}
753889
public function compileSelect(Builder $query)
    {
        if (is_null($query->columns)) {
            $query->columns = ['*'];
        }

        $components = $this->compileComponents($query);

        // If an offset is present on the query, we will need to wrap the query in
        // a big "ANSI" offset syntax block. This is very nasty compared to the
        // other database systems but is necessary for implementing features.
        if ($this->isPaginationable($query, $components)) {
            return $this->compileAnsiOffset($query, $components);
        }

        return trim($this->concatenate($components));
    }
1306451
protected function parseQuery(QueryInterface $query) {
        $operationList = $query->getStoredQueryCriteria();
        $pos = 0;
        foreach ($operationList as $operation) {
            if($pos > 0) {
                $this->addSeparator(true);
            }
            $this->parseOperation($operation);
            $pos++;
            
        }
        return $this;
    }
589950
public static Program compileSql(String query) {
        try {
            ANTLRStringStream in = new ANTLRStringStream(query);
            druidGLexer lexer = new druidGLexer(in);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            druidGParser parser = new druidGParser(tokens);
            Program pgm = parser.program();
            return pgm;
        } catch (RecognitionException ex) {
            System.out.println(ex);
            Logger.getLogger(DCompiler.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
173498
function execute(WriterInterface $query, callable $callback) {
		$this->result = null;
		$this->query = $query;
		$this->notify();
		
		list($context, $resolver) = $this->prepareCallbacks(
			function(\pq\Result $result) {
				$this->result = $result;
				$this->notify();
				return $result;
			}, $callback);
		$this->getConnection()->execParamsAsync($query, $query->getParams(), 
			$query->getTypes(), $resolver);
		return $context;
	}
961657
public function compileSelect(Builder $query)
    {
        if ($query->unions && $query->aggregate) {
            return $this->compileUnionAggregate($query);
        }

        $sql = parent::compileSelect($query);

        if ($query->unions) {
            $sql = '('.$sql.') '.$this->compileUnions($query);
        }

        return $sql;
    }
1170056
public function transform($query) {
        $usePatch = isset($this->options['driverOptions']['use_patch']) ? $this->options['driverOptions']['use_patch'] : false;
        
        $tokens     = $this->parser->parse($query);
        $method     = HttpMethods::ofSqlOperation(SqlOperation::create($tokens), $usePatch);
        $annotation = Annotation::get($this->routings, Table::create($tokens), $method);

        return $this->requestFactory->createOne($method, $tokens, $this->options, $annotation);
    }
769416
protected function executeAndGetResultsAsEntityIterator(PreparableSqlInterface $query)
    {
        $entities = $this->execute($query)
            ->toEntityArray();

        return new EntityIterator($entities);
    }
1362683
public function load(Queries\Interfaces\SearchQueryInterface $query): ServiceInterface
    {
        $this->query = $query;

        $parameters = [
            static::INPUT => trim($this->query->getInput()),
            static::SESSION_TOKEN => $this->query->getToken(),
            static::LANGUAGE => $this->query->getLanguage()->getValue(),
            static::COMPONENTS => static::COUNTRY . mb_strtolower($this->config->getCountry()),
            static::KEY => $this->config->getKey(),
        ];

        if ($this->query instanceof Queries\Interfaces\CitySearchInterface) {
            $parameters[static::TYPE] = static::CITIES;
        } elseif ($this->query instanceof Queries\Interfaces\StreetSearchInterface) {
            $parameters[static::INPUT] = trim($this->query->getType()) . ' ' . $parameters[static::INPUT];
            $parameters[static::TYPE] = static::ADDRESS;
        } else {
            throw new Exceptions\InvalidQueryType($this->query);
        }

        $response = $this->client->request('GET', $this->config->getUrl(), [
            GuzzleHttp\RequestOptions::QUERY => $parameters,
        ]);

        $responseBody = $response->getBody();
        $data = json_decode($responseBody, true);

        if (json_last_error() !== JSON_ERROR_NONE || !array_key_exists(static::STATUS, $data)) {
            throw new Exceptions\InvalidResponse($response);
        }

        $status = new Enums\SearchStatus($data[static::STATUS]);

        $this->validateStatus($status);

        if ($this->existPredictionWrapper($data)) {
            $this->locations = $this->fetchResults($data[static::PREDICTION_COLLECTION]);
        }

        return $this;
    }
415632
public function compileSelect(Builder $query)
	{
		$original = $query->columns;

		if (is_null($query->columns)) {
			$query->columns = ['*'];
		}

		$components = $this->compileComponents($query);

		// If an offset is present on the query, we will need to wrap the query in
		// a big "ANSI" offset syntax block. This is very nasty compared to the
		// other database systems but is necessary for implementing features.
		if ($query->offset > 0) {
			return $this->compileAnsiOffset($query, $components);
		}

		$sql = $this->concatenate($components);

		$query->columns = $original;

		return $sql;
	}