我有一个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 Job中使用这个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 回答
你能分享你的剧本的样子吗?特别是,你呢?
使用Visual Studio的代码后面的代码?
如果1的答案为否:您是否使用
CREATE ASSEMBLY
或通过Visual Studio程序集注册功能在U-SQL目录中注册了Outputter和Newtonsoft lib?你是否用REFERENCE ASSEMBLY
在脚本中引用了U-SQL程序集(包括你自己的代码和Newtonsoft)?更多细节:https://blogs.msdn.microsoft.com/azuredatalake/2016/08/26/how-to-register-u-sql-assemblies-in-your-u-sql-catalog/