You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Daniil Kirilyuk (Jira)" <ji...@apache.org> on 2022/06/21 07:20:00 UTC

[jira] [Created] (QPID-8592) [Broker-J] Pass context value from parent query into the subquery

Daniil Kirilyuk created QPID-8592:
-------------------------------------

             Summary: [Broker-J] Pass context value from parent query into the subquery
                 Key: QPID-8592
                 URL: https://issues.apache.org/jira/browse/QPID-8592
             Project: Qpid
          Issue Type: Improvement
          Components: Broker-J
    Affects Versions: qpid-java-broker-8.0.6
            Reporter: Daniil Kirilyuk


Current version of broker query engine doesn't support subqueries referencing fields from the parent query. To support this possibility it's needed to pass the context from parent query to the subquery.

To pass context from parent query to the subquery it's needed to add current stream item and it's alias to the Evaluation context. It can be done using Stream#peek() inside of SelectEvaluator#evaluate(). 

As the aliases from parent query will affect subquery sorting, it also will be required to consider added aliases in QueryEvaluator#createComparator().

This should allow to use values from parent queries in subqueries, e.g.:
{code:java}
SELECT 
 id, 
 name, 
 (SELECT name FROM connection WHERE SUBSTRING(name, 1, POSITION(']' IN name)) = '[' + SUBSTRING(c.name, 1, POSITION('|' IN c.name) - 1) + ']') as connection, 
 (SELECT id FROM connection WHERE SUBSTRING(name, 1, POSITION(']' IN name)) = '[' + SUBSTRING(c.name, 1, POSITION('|' IN c.name) - 1) + ']') as connectionId, 
 (SELECT name FROM session WHERE id = c.session.id) as session 
FROM consumer c{code}
or
{code:java}
SELECT 
 name, 
 destination, 
 (SELECT id FROM queue WHERE name = b.destination) AS destinationId, 
 exchange, 
 (SELECT id FROM exchange WHERE name = b.exchange) AS exchangeId 
FROM binding b 
WHERE name = 'broadcast.amqp_user1.xxx.#'{code}
or
{code:java}
SELECT 
 alias, 
 (SELECT COUNT(id) FROM queue WHERE POSITION(UPPER(c.alias) IN name) > 0) AS queueCount 
FROM certificate c{code}
This would allow to retrieve values from associated entities without firing additional queries.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org