[英]Update in USQL Azure Data lake
Is there any way by which I can update a value in rowset 有什么方法可以更新行集中的值
Data: 数据:
1,apple,0
2,check,1
3,chec,1
USQL script: USQL脚本:
@result = EXTRACT
ID int,
value string,
types int
FROM @"TLD_BT/sacmple.txt"
USING Extractors.Csv();
Now I would like to update the above result set @result set type =1 where value is apple 现在我想更新以上结果集@result set type = 1,其中值是apple
I tried below script. 我尝试了以下脚本。
UPDATE @result SET types=1 WHERE value="apple"
But I get below error: 但我得到以下错误:
UPDATE ### @result SET types=1 WHERE value="apple"
Error
E_CSC_USER_SYNTAXERROR
Message
syntax error. Expected one of: STATISTICS
Is there anyway by which I can update the value of a rowset or should I find out any other work around. 无论如何,我可以通过它来更新行集的值,还是应该找出其他解决方法。
There is no UPDATE
command in U-SQL at this time but you could use the conditional statement to create a new column and output that. 目前,U-SQL中没有
UPDATE
命令,但是您可以使用条件语句来创建新列并将其输出。 You could also use the CTAS syntax to create a new internal table. 您还可以使用CTAS语法创建新的内部表。 Examples below:
以下示例:
@result =
EXTRACT [ID] int,
value string,
types int
FROM @"input/input.txt"
USING Extractors.Csv();
//UPDATE @result SET types=1 WHERE value="apple"
@output =
SELECT [ID] AS id,
value,
value == "apple"? 1 : types AS types
FROM @result;
// CTAS
CREATE TABLE IF NOT EXISTS dbo.interimResult
(
INDEX cdx_Result
CLUSTERED(id)
DISTRIBUTED BY
ROUND ROBIN
)
AS
SELECT [ID] AS id,
value,
value == "apple"? 1 : types AS types
FROM @result;
// output result
OUTPUT @output TO "/output/adlaresult.csv"
USING Outputters.Csv();
Hope that makes sense. 希望有道理。 Also see here: U-SQL DML Statements
另请参见此处: U-SQL DML语句
if you want to update the same table , we create a new partition and insert both Unchanged as well as new records. 如果您想更新同一张表,我们将创建一个新分区,并插入Unchanged和新记录。 In this way new partition will always have latest dataset
这样,新分区将始终具有最新的数据集
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.