How to throw a error or raise exception in U-SQL?

最后都变了- 提交于 2021-01-28 00:31:44

问题


What is the mechanism used to raise an error or exception in a U-Sql script? I have a scenario where am processing a CSV file, and if duplicates are found in it, then I need to abandon processing.

In SQL, I could do raiseerror, what it the equivalent way of doing it in U-Sql?


回答1:


Create a c# function to raise custom errors (or output to a file):

DECLARE @RaiseError Func<string, int> = (error) => 
    {
        throw new Exception(error);
        return 0;
    };

@Query = 
    SELECT @RaiseError(value) AS ErrorCode
    FROM (VALUES ("my custom error description")) AS T(value);

OUTPUT @Query TO "/Output/errors.txt" USING Outputters.Csv(quoting : true);


来源:https://stackoverflow.com/questions/51963804/how-to-throw-a-error-or-raise-exception-in-u-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!