2016-05-23 17 views
1

2 SA入力からの入力を1 SA出力に結合する方法が必要です。ストリームアナリティック(SA)複数入力と1出力

例:

私は2つの入力からデータを読み込もうと

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 
「重複出力名が許可されていません」と言った例外を取得プット(SQL表) うちの一つに入れたいのです

答えて

4

両方のクエリのデータ型が同じであるように見えるので、UNIONを使用して2つのクエリの出力を1つに結合してSQLテーブルに出力することができます。ここで

は、クエリの書き直したものです:

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 
関連する問題