提交HDInsight Pig作业



PigHadoop常用的一个模块,Azure提供了使用PowerShell提交Pig作业的方式,当Pig Latin的脚本较为短小时,可使用New-AzureHDInsightPigJobDefinition-Query直接指定脚本内容,示例如下:

$clusterName = "HDIDemo"
$QueryString = "intxt1 = load 'wasb://hdirawdata@teststorage.blob.core.chinacloudapi.cn/userbehavior.log' ;" +
	"store intxt1 into 'wasb:///home/mytest1' ;"
	
$pigJobDefinition = New-AzureHDInsightPigJobDefinition -Query $QueryString  

$pigJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $pigJobDefinition 
 
Wait-AzureHDInsightJob -Job $pigJob -WaitTimeoutInSeconds 3600

Write-Host "Display the standard output ..." -ForegroundColor Green
Get-AzureHDInsightJobOutput -Cluster $clusterName -JobId $pigJob.JobId -StandardError  


PigLatin的脚本过长时,则会遇到”Theinput line is too long”的错误,这是由于一次提交的batch过长而导致,这时调用PigLatin文本就显得尤为重要。具体方法如下:


  1. 将如下Pig Latin的脚本存于后缀名为.pig的文件中(本例中为PigLatinTest.pig),并将其存储于Azureblob storage中。

    intxt1 = load'wasb://amberhdirawdata@amberstorage.blob.core.chinacloudapi.cn/userbehavior.log';

    store intxt1 into 'wasb:///home/mytest1' ;

  2. 使用如下命令调用Pig Latin脚本、并执行Pig作业:



$clusterName = "AmberHDIDemo"

$pigJobDefinition = New-AzureHDInsightPigJobDefinition -File "wasb://hdirawdata@teststorage.blob.core.chinacloudapi.cn/userbehavior.pig" -StatusFolder $statusFolder  -Verbose

$pigJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $pigJobDefinition 
 
Wait-AzureHDInsightJob -Job $pigJob -WaitTimeoutInSeconds 3600

# Print the output of the Pig job.
Write-Host "Display the standard output ..." -ForegroundColor Green
Get-AzureHDInsightJobOutput -Cluster $clusterName -JobId $pigJob.JobId -StandardError 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值