Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> Boolean pig UDF constructor


+
meghana narasimhan 2012-11-08, 18:29
+
Jonathan Coveney 2012-11-08, 18:35
+
meghana narasimhan 2012-11-08, 18:42
Copy link to this message
-
Re: Boolean pig UDF constructor
Hi Meghana,

UDFs accept String arguments in the constructor. You would have to
pass in the Boolean value as a string ('true' or 'false') and handle
that in your constructor.

Sent from my iPhone

On Nov 8, 2012, at 10:30 AM, meghana narasimhan
<[EMAIL PROTECTED]> wrote:

> Hi All,
>
> Can I pass in a boolean value to Pig UDF constructor with Pig 0.9.2?
>
> I have a constructor :
>
> public GenStartEndDate(boolean mtdNoGlob) {
>
>        this.mtdNoGlob = mtdNoGlob;
>
>    }
>
>
> I am instantiating it in my Pig script :
>
>
> DEFINE START_END_DATE com.demandmedia.dig.udf.GenStartEndDate(false);
>
>
> I get :
>
>
> org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error
> during parsing. <line 4, column 62>  mismatched input 'false' expecting
> RIGHT_PAREN
>
> at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1641)
>
> at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1584)
>
> at org.apache.pig.PigServer.registerQuery(PigServer.java:584)
>
> at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:967)
>
> at org.apache.pig.pigunit.pig.GruntParser.processPig(GruntParser.java:61)
>
> at
> org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:386)
>
> at
> org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:189)
>
> at org.apache.pig.pigunit.pig.PigServer.registerScript(PigServer.java:53)
>
> at org.apache.pig.pigunit.PigTest.registerScript(PigTest.java:160)
>
> at org.apache.pig.pigunit.PigTest.runScript(PigTest.java:170)
>
> at
> com.demandmedia.dig.incite.TestSiteUrlDaily.testBasic(TestSiteUrlDaily.java:84)
>
> Caused by: Failed to parse: <line 4, column 62>  mismatched input 'false'
> expecting RIGHT_PAREN
>
> at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:222)
>
> at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:164)
>
> at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1633)
>
> ... 43 more
>
>
> I also tried :
>
> DEFINE START_END_DATE com.demandmedia.dig.udf.GenStartEndDate('false');
>
>
> with :
>
>
> <line 138, column 10> Failed to generate logical plan. Nested exception:
> java.lang.RuntimeException: could not instantiate
> 'com.demandmedia.dig.udf.GenStartEndDate' with arguments '[false]'
>
> at
> org.apache.pig.parser.LogicalPlanBuilder.buildUDF(LogicalPlanBuilder.java:912)
>
> at
> org.apache.pig.parser.LogicalPlanGenerator.func_eval(LogicalPlanGenerator.java:7047)
>
> at
> org.apache.pig.parser.LogicalPlanGenerator.projectable_expr(LogicalPlanGenerator.java:8583)
>
> at
> org.apache.pig.parser.LogicalPlanGenerator.var_expr(LogicalPlanGenerator.java:8358)
>
> at
> org.apache.pig.parser.LogicalPlanGenerator.expr(LogicalPlanGenerator.java:7711)
>
>
> What am I doing wrong?
>
> - Meg
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB