U-SQL 比较标量表达式中的行集数据
U-SQL Compare Rowset Data in scalar expression
我浏览了一些无法进行转换的文章,但是我遇到了一个问题,即在行集中提取了一个值,并且需要在标量表达式中使用该值。
ColumnA 是一个字符串值,ColumnB 是一个 Int..
@RequiredData = SELECT [ColumnA] from @Input ORDER BY [ColumnB] ASC
FETCH 1 ROWS;
IF((@RequiredData == "Something")) THEN
//DO SOMETHING
END;
这在 ADLA 中失败并出现问题 Rowset variable @RequiredData is not a scalar variable。
U-SQL 是一种声明性语言,控制流有限。您可以将您的逻辑转换为基于集合的逻辑,这将起作用,例如
@someOtherData =
SELECT * FROM
( VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9)
) AS x(y);
@Input =
SELECT * FROM
( VALUES
("Something", 1),
("Nothing", 2)
) AS x(ColumnA, ColumnB);
@RequiredData = SELECT [ColumnA] FROM @Input ORDER BY [ColumnB] ASC
FETCH 1 ROWS;
// IF((@RequiredData == "Something")) THEN
@output =
SELECT d.*
FROM @someOtherData AS d
CROSS JOIN
@RequiredData AS rd
WHERE rd.ColumnA == "Something";
OUTPUT @output
TO "/output/output.txt"
USING Outputters.Tsv();
如果值不是 "Something",这将输出一个空文件。
我浏览了一些无法进行转换的文章,但是我遇到了一个问题,即在行集中提取了一个值,并且需要在标量表达式中使用该值。
ColumnA 是一个字符串值,ColumnB 是一个 Int..
@RequiredData = SELECT [ColumnA] from @Input ORDER BY [ColumnB] ASC
FETCH 1 ROWS;
IF((@RequiredData == "Something")) THEN
//DO SOMETHING
END;
这在 ADLA 中失败并出现问题 Rowset variable @RequiredData is not a scalar variable。
U-SQL 是一种声明性语言,控制流有限。您可以将您的逻辑转换为基于集合的逻辑,这将起作用,例如
@someOtherData =
SELECT * FROM
( VALUES
(1),(2),(3),(4),(5),(6),(7),(8),(9)
) AS x(y);
@Input =
SELECT * FROM
( VALUES
("Something", 1),
("Nothing", 2)
) AS x(ColumnA, ColumnB);
@RequiredData = SELECT [ColumnA] FROM @Input ORDER BY [ColumnB] ASC
FETCH 1 ROWS;
// IF((@RequiredData == "Something")) THEN
@output =
SELECT d.*
FROM @someOtherData AS d
CROSS JOIN
@RequiredData AS rd
WHERE rd.ColumnA == "Something";
OUTPUT @output
TO "/output/output.txt"
USING Outputters.Tsv();
如果值不是 "Something",这将输出一个空文件。