如何在U-SQL中引发错误或引发异常? [英] How to throw a error or raise exception in U-SQL?

查看:72
本文介绍了如何在U-SQL中引发错误或引发异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在U-Sql脚本中引发错误或异常的机制是什么?我有一个正在处理CSV文件的场景,如果发现重复文件,则需要放弃处理.

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.

在SQL中,我可以执行 raiseerror ,它在U-Sql中的等效方法是什么?

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

推荐答案

创建一个c#函数以引发自定义错误(或输出到文件):

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);

这篇关于如何在U-SQL中引发错误或引发异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆