在U-SQL中运行R脚本

时间:2018-12-11 11:56:23

标签: r u-sql

使用R扩展运行示例USQL时,出现此错误

****"message": "Error Id: VertexFailedFast, Error Message: Vertex failed with a fail-fast error. "**** 






REFERENCE ASSEMBLY [ExtR];   //enable R extensions for the U-SQL Script

//declare the R script as a string variable and pass it as a parameter to the Reducer:
DECLARE @myRScript = @"
inputFromUSQL$species <- as.factor(inputFromUSQL$species),
lm.fit <- lm(unclass(species)~.-Par, data=inputFromUSQL),
summary(lm.fit)
";

DECLARE @myInputFile string   = @"/dev/iris.csv";
DECLARE @myOutputFile string = @"/dev/outex6b.txt";

@InputIrisData = EXTRACT 
sepal_length string,
sepal_width string,
petal_length string,
petal_width string,
species string  
FROM @myInputFile
USING Extractors.Csv(skipFirstNRows: 1);
//USING Extractors.Csv();  //if myInputFile file has no headers



@ExtendedData = SELECT 
0 AS Par,
*
FROM @InputIrisData;

@RScriptOutput = REDUCE @ExtendedData ON Par PRODUCE 
Par, 
RowId int,
ROutput string
USING new Extension.R.Reducer(command:@myRScript, rReturnType:"charactermatrix");


//OUTPUT @RScriptOutput TO @myOutputFile USING Outputters.Tsv();    
OUTPUT @RScriptOutput TO @myOutputFile USING Outputters.Csv(outputHeader : true, quoting:false);  //if want the headers as well

我的示例输入是:

sepal_length,sepal_width,petal_length,petal_width,label
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa

0 个答案:

没有答案