datafu.pig.util
Class Coalesce
java.lang.Object
org.apache.pig.EvalFunc<T>
datafu.pig.util.ContextualEvalFunc<T>
datafu.pig.util.AliasableEvalFunc<java.lang.Object>
datafu.pig.util.Coalesce
public class Coalesce
- extends AliasableEvalFunc<java.lang.Object>
Returns the first non-null value from a tuple, just like COALESCE in SQL.
Example:
define COALESCE datafu.pig.util.COALESCE();
-- input: 1,2,3,NULL,4,NULL,5
input = LOAD 'input' AS (val:int);
-- produces: 1,2,3,99,4,99,5
coalesced = FOREACH input GENERATE COALESCE(val,99);
- Author:
- "Matthew Hayes "
Fields inherited from class org.apache.pig.EvalFunc |
log, pigLogger, reporter, returnType |
Method Summary |
java.lang.Object |
exec(org.apache.pig.data.Tuple input)
|
org.apache.pig.impl.logicalLayer.schema.Schema |
getOutputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
Specify the output schema as in {link EvalFunc#outputSchema(Schema)}. |
Methods inherited from class datafu.pig.util.AliasableEvalFunc |
getBag, getBoolean, getDouble, getDouble, getFieldAliases, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getObject, getPosition, getPosition, getPrefixedAliasName, getString, getString, outputSchema |
Methods inherited from class org.apache.pig.EvalFunc |
finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, progress, setInputSchema, setPigLogger, setReporter, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Coalesce
public Coalesce()
Coalesce
public Coalesce(java.lang.String option)
exec
public java.lang.Object exec(org.apache.pig.data.Tuple input)
throws java.io.IOException
- Specified by:
exec
in class org.apache.pig.EvalFunc<java.lang.Object>
- Throws:
java.io.IOException
getOutputSchema
public org.apache.pig.impl.logicalLayer.schema.Schema getOutputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)
- Description copied from class:
AliasableEvalFunc
- Specify the output schema as in {link EvalFunc#outputSchema(Schema)}.
- Specified by:
getOutputSchema
in class AliasableEvalFunc<java.lang.Object>
- Returns:
- outputSchema
Matthew Hayes, Sam Shah