Search in sources :

Example 1 with DelimitedJSONSerDe

use of org.apache.hadoop.hive.serde2.DelimitedJSONSerDe in project SQLWindowing by hbutani.

the class QueryOutputPrinter method setupOutputSerDe.

private SerDe setupOutputSerDe(QueryDef qry, JobConf jcfg) throws WindowingException {
    try {
        //			StructObjectInspector qOI = qry.getOutput().getOI();
        //			String cols = ObjectInspectorUtils.getFieldNames(qOI);
        //			String ctypes = ObjectInspectorUtils.getFieldTypes(qOI);
        /* from FetchWork initialize */
        String serdeName = HiveConf.getVar(jcfg, HiveConf.ConfVars.HIVEFETCHOUTPUTSERDE);
        Class<? extends SerDe> serdeClass = Class.forName(serdeName, true, JavaUtils.getClassLoader()).asSubclass(SerDe.class);
        SerDe serDe = (SerDe) ReflectionUtils.newInstance(serdeClass, null);
        Properties serdeProp = new Properties();
        // this is the default serialization format
        if (serDe instanceof DelimitedJSONSerDe) {
            serdeProp.put(Constants.SERIALIZATION_FORMAT, "" + Utilities.tabCode);
            serdeProp.put(Constants.SERIALIZATION_NULL_FORMAT, "NULL");
        }
        serDe.initialize(jcfg, serdeProp);
        return serDe;
    } catch (Exception e) {
        throw new WindowingException(e);
    }
}
Also used : SerDe(org.apache.hadoop.hive.serde2.SerDe) DelimitedJSONSerDe(org.apache.hadoop.hive.serde2.DelimitedJSONSerDe) DelimitedJSONSerDe(org.apache.hadoop.hive.serde2.DelimitedJSONSerDe) WindowingException(com.sap.hadoop.windowing.WindowingException) Properties(java.util.Properties) WindowingException(com.sap.hadoop.windowing.WindowingException)

Aggregations

WindowingException (com.sap.hadoop.windowing.WindowingException)1 Properties (java.util.Properties)1 DelimitedJSONSerDe (org.apache.hadoop.hive.serde2.DelimitedJSONSerDe)1 SerDe (org.apache.hadoop.hive.serde2.SerDe)1