我需要一种方法,可以将2 SA输入的输入与1 SA输出结合起来。
例如
我正在尝试从两个输入读取数据并希望将它们放在一个输出中(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
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
答案 0 :(得分:5)
由于两个查询的数据类型似乎相同,因此您可以使用UNION将两个查询的输出合并为一个,然后输出到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