brickhouse.udf.json
Class FromJsonUDF

java.lang.Object
  extended by org.apache.hadoop.hive.ql.udf.generic.GenericUDF
      extended by brickhouse.udf.json.FromJsonUDF

public class FromJsonUDF
extends org.apache.hadoop.hive.ql.udf.generic.GenericUDF

Generate an arbitrary Hive structure from a JSON string, and an example template object. The UDF takes a JSON string as the first argument, and the second argument defines the return type of the UDF, and which fields are parsed from the JSON string. To parse JSON maps with values of varying types, use struct() to create a structure with the desired JSON keys. The template object should be constant. For example, from_json( " { "name":"Bob","value":23.0,colors["red","yellow","green"], "inner_map":{"a":1,"b":2,"c":3 }" , struct("name", "","value", 0.0,"colors", array(""), "inner_map", map("",1) );


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject, org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject
 
Constructor Summary
FromJsonUDF()
           
 
Method Summary
 Object evaluate(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject[] arg0)
           
static String FromCamelCase(String camel)
          Converts from CamelCase to a string containing underscores.
 String getDisplayString(String[] arg0)
           
 org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector initialize(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector[] arg0)
           
static String ToCamelCase(String underscore)
           
 
Methods inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
getRequiredFiles, getRequiredJars, initializeAndFoldConstants
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FromJsonUDF

public FromJsonUDF()
Method Detail

evaluate

public Object evaluate(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject[] arg0)
                throws org.apache.hadoop.hive.ql.metadata.HiveException
Specified by:
evaluate in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
Throws:
org.apache.hadoop.hive.ql.metadata.HiveException

getDisplayString

public String getDisplayString(String[] arg0)
Specified by:
getDisplayString in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF

initialize

public org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector initialize(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector[] arg0)
                                                                         throws org.apache.hadoop.hive.ql.exec.UDFArgumentException
Specified by:
initialize in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
Throws:
org.apache.hadoop.hive.ql.exec.UDFArgumentException

ToCamelCase

public static String ToCamelCase(String underscore)

FromCamelCase

public static String FromCamelCase(String camel)
Converts from CamelCase to a string containing underscores.

Parameters:
camel -
Returns:


Copyright © 2013. All rights reserved.