locked
UNION returns no results if one query is empty RRS feed

  • Question

  • Hi,

    We are running into some problems when using the UNION statement in an Azure Stream Analytics Job. If one of the queries does not return any results, the UNION does not return any results either, even if the other queries do contain results.

    Here is one test query, where I would expect the result to contain one row with Value = 2. However, the result of the query is empty.

    SELECT 1 AS Value
    FROM [Input]
    WHERE 1 = 0
    
    UNION ALL
    
    SELECT 2 AS Value
    FROM [Input]
    WHERE 2 = 2

    If both queries return data, then UNION ALL statement works as expected. For example, the following query does return two rows with values 1 and 2:

    SELECT 1 AS Value
    FROM [Input]
    WHERE 1 = 1
    
    UNION ALL
    
    SELECT 2 AS Value
    FROM [Input]
    WHERE 2 = 2


    Does anyone have some insight into what is happening? Any help would be much appreciated.

    Thanks,

    Pedro

    Thursday, April 20, 2017 8:16 AM

All replies

  • Hi Pedro,

    It may be that you simplified your real query too much, but the examples you provided work as you expect.
    I've tried both running job and via test feature in portal and I do get results for both queries in your question.

    As long as thereare some events being sent to [Input] there will be progress in time, and union will generate results as well.

    If you can provide more details at what exactly you do to reproduce the problem you reported we can help look into it further.

    Thanks,
    Alex.


    Azure Stream Analytics.

    Tuesday, April 25, 2017 11:04 PM