On 15 September 2015 at 00:09, Gopal Vijayaraghavan <gop...@apache.org>
wrote:

> CTE


Thank you for the in depth reply Gopal. I've just had a quick try out of
CTEs but can't see how they address my original problem of decomposing a
query into separate independent units. It seems that the CTE definition ('
with' clause) must always be immediately followed by the use of the CTE ('
select' for example). Therefore, the CTE queries must still be inlined into
the parent queries, creating one monolithic query.

My goal is to create separate independent processing units (queries) that
can then be composed into larger queries. Effectively something like:

WITH a AS (SELECT ... FROM A);
// I would now like to be able to test 'a'

// This can be in a separate file imported with 'source'



WITH b AS (SELECT ... FROM B);
// I would now like to be able to test 'b'
// This can be in a separate file imported with 'source'


// Compose 'a' and 'b'

SOURCE a.hql;

SOURCE b.hql;

WITH c AS (
    SELECT ... FROM (
        SELECT ... FROM a WHERE ...
    ) A LEFT JOIN (
        SELECT ... FROM b
    ) B ON (...)
);
// I would now like to be able to test the composition 'c'
// that uses both 'a' and 'b'.
// This can be in a separate file imported with 'source'


Thanks - Elliot.

Reply via email to