USQL - 自定义输出器无法找到NewtonSoft

时间:2018-03-30 09:27:59

标签: c# azure visual-studio-code azure-data-lake u-sql

我有一个USQL作业,它从Azure Blob读取json,并在一些数据操作之后将单行JSON文件写入ADLS。 我写了一个Custom Ouputter来编写JSON文件。

这就是我的CustomOutputter文件的样子:

    using Microsoft.Analytics.Interfaces;
    using Microsoft.Analytics.Types.Sql;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using Newtonsoft.Json;
    namespace demo{

    [SqlUserDefinedOutputter(AtomicFileProcessing = true)]
    public class JSONOutputter : IOutputter
    {
     //Actual Code Here
     public static class Factory
    {
        public static JSONOutputter JSONOutputter(bool isHeader = true, Encoding encoding = null)
        {
        return new JSONOutputter(isHeader, encoding);
        }
    }
    }

我在我的USQL工作中使用这个Ouputter是这样的:

    OUTPUT @final_output
    TO "/output/json/final.json"
    USING demo.Factory.JSONOutputter(isHeader: true);

当我使用

编译我的USQL脚本时
ADL: Compile Script

我收到此错误:

    [Info] Start compiling code behind: /users/kumar.pratik/documents/usql/second.usql.cs ...
    [Error] Command failed: mono /Users/kumar.pratik/.vscode/extensions/usqlextpublisher.usql-vscode-ext-0.2.11/compilehost/compilehost.exe /users/kumar.pratik/documents/usql/second.usql.cs  /Users/kumar.pratik/Documents/usql/usqlCodeBehindReference /Users/kumar.pratik/Documents/usql/second.usql.dll __codeBehind__tRYGlFBeSWcl

    [Error] Compile failed

    error: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" at line: 8, column 6
    error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 17, column 12
    error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 44, column 34

有人可以告诉我如何解决这个问题?

我正在使用Mac OS上的Visual Studio Code

由于

1 个答案:

答案 0 :(得分:0)

你能分享你的剧本的样子吗?特别是,你是

吗?
  1. 使用Visual Studio代码后面的输出代码?
  2. 如果1的答案为否:您是否使用CREATE ASSEMBLY或通过Visual Studio程序集注册功能在U-SQL目录中注册了Outputter和Newtonsoft lib?您是否在脚本中使用REFERENCE ASSEMBLY引用了U-SQL程序集(包括您自己的代码和Newtonsoft)?
  3. 更多详情:https://blogs.msdn.microsoft.com/azuredatalake/2016/08/26/how-to-register-u-sql-assemblies-in-your-u-sql-catalog/