2016-05-23 9 views
1

Ich brauche einen Weg, wo ich die Eingabe von 2 SA Eingang zu 1 SA Ausgang kombinieren kann.Stream Analytic (SA) Mehrere Eingänge und ein Ausgang

Eg

Ich versuche, auf die Daten von zwei Eingabe zu lesen und wollen sie setzen (SQL-Tabelle) in einer aus setzen eine Ausnahme Erste sagen

„Duplicate Ausgangsnamen sind nicht erlaubt“
SELECT 
    Input.internal.data.id AS id, 
    Input.context.data.eventtime AS eventtime, 
    recordProperty.PropertyName AS name, 
    Cast(recordProperty.PropertyValue.Value AS bigint) AS value 
INTO 
    [output-custommetric] 
FROM 
    [input-custommetric] AS Input TIMESTAMP BY Input.context.data.eventtime 
    CROSS APPLY GetElements(Input.[context].[custom].[metrics]) AS flat 
    CROSS APPLY GetRecordProperties(Flat.ArrayValue) AS recordProperty 

SELECT 
    Input.internal.data.id AS id, 
    Input.context.data.eventtime AS eventtime, 
    recordProperty.PropertyName AS name, 
    Cast(recordProperty.PropertyValue.Value AS bigint) AS value 
INTO 
    [output-custommetric] 
FROM 
    [input-slacustommetric] AS Input TIMESTAMP BY Input.context.data.eventtime 
    CROSS APPLY GetElements(Input.[context].[custom].[metrics]) AS flat 
    CROSS APPLY GetRecordProperties(Flat.ArrayValue) AS recordProperty 

Antwort

4

Da der Datentyp beider Abfragen identisch zu sein scheint, können Sie UNION verwenden, um die Ausgaben Ihrer beiden Abfragen zu einer zu kombinieren, bevor Sie sie in die SQL-Tabelle ausgeben.

Hier ist Umschreiben der Anfrage:

SELECT 
    Input.internal.data.id AS id, 
    Input.context.data.eventtime AS eventtime, 
    recordProperty.PropertyName AS name, 
    Cast(recordProperty.PropertyValue.Value AS bigint) AS value 
INTO 
    [output-custommetric] 
FROM 
    [input-custommetric] AS Input TIMESTAMP BY Input.context.data.eventtime 
    CROSS APPLY GetElements(Input.[context].[custom].[metrics]) AS flat 
    CROSS APPLY GetRecordProperties(Flat.ArrayValue) AS recordProperty 
UNION 
SELECT 
    Input.internal.data.id AS id, 
    Input.context.data.eventtime AS eventtime, 
    recordProperty.PropertyName AS name, 
    Cast(recordProperty.PropertyValue.Value AS bigint) AS value 
FROM 
    [input-slacustommetric] AS Input TIMESTAMP BY Input.context.data.eventtime 
    CROSS APPLY GetElements(Input.[context].[custom].[metrics]) AS flat 
    CROSS APPLY GetRecordProperties(Flat.ArrayValue) AS recordProperty