Search in sources :

Example 1 with QueryOutputSpec

use of com.sap.hadoop.windowing.query2.specification.QueryOutputSpec in project SQLWindowing by hbutani.

the class MRUtils method getOutputPath.

public String getOutputPath() {
    QueryOutputSpec qOutSpec = qdef.getOutput().getOutputSpec();
    outputPath = qOutSpec.getPath();
    return outputPath;
}
Also used : QueryOutputSpec(com.sap.hadoop.windowing.query2.specification.QueryOutputSpec)

Example 2 with QueryOutputSpec

use of com.sap.hadoop.windowing.query2.specification.QueryOutputSpec in project SQLWindowing by hbutani.

the class OutputTranslation method validateOutputSpec.

public static void validateOutputSpec(QueryDef qDef) throws WindowingException {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QueryOutputSpec spec = qDef.getSpec().getOutput();
    // ensure outputPath is specified. It is optional in grammar because it is not required in Hive mode.
    if (spec == null || spec.getPath() == null) {
        throw new WindowingException("Query doesn't contain an output Path for results");
    }
    // if tableName is specified; validate it exists
    Table oTbl = null;
    if (spec.getHiveTable() != null) {
        oTbl = getHiveTableDetails(tInfo.getHiveCfg(), spec.getHiveTable(), qDef.getInput().getHiveTableSpec());
    }
    // validate serDeClass
    if (spec.getSerDeClass() == null) {
        if (oTbl != null && oTbl.getSd().getSerdeInfo().isSetSerializationLib()) {
            spec.setSerDeClass(oTbl.getSd().getSerdeInfo().getSerializationLib());
            if (oTbl.getSd().getSerdeInfo().isSetParameters()) {
                Iterator<Map.Entry<String, String>> props = oTbl.getSd().getSerdeInfo().getParameters().entrySet().iterator();
                while (props.hasNext()) {
                    Map.Entry<String, String> e = props.next();
                    spec.addSerdeProperty(e.getKey(), e.getValue());
                }
            }
        } else {
            spec.setSerDeClass(com.sap.hadoop.windowing.Constants.DEFAULT_SERDE_CLASSNAME);
            spec.addSerdeProperty(org.apache.hadoop.hive.serde.Constants.FIELD_DELIM, ",");
        }
    }
    try {
        Class.forName(spec.getSerDeClass());
    } catch (Throwable t) {
        throw new WindowingException(sprintf("Unknown SerDe Class %s", spec.getSerDeClass()), t);
    }
    // validate outputFormat
    if (spec.getOutputFormatClass() == null) {
        if (oTbl != null) {
            spec.setOutputFormatClass(oTbl.getSd().getOutputFormat());
        } else {
            spec.setOutputFormatClass(Constants.DEFAULT_OUTPUTFORMAT_CLASSNAME);
        }
    }
    try {
        Class.forName(spec.getOutputFormatClass());
    } catch (Throwable t) {
        throw new WindowingException(sprintf("Unknown OutputFormat Class %s", spec.getOutputFormatClass()), t);
    }
    // ensure user has not specified a FormatClass
    if (spec.getRecordWriterClass() != null) {
        throw new WindowingException("Illegal Output Spec: RecordWriter class not valid in MR mode");
    }
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) QueryOutputSpec(com.sap.hadoop.windowing.query2.specification.QueryOutputSpec) WindowingException(com.sap.hadoop.windowing.WindowingException) Map(java.util.Map)

Aggregations

QueryOutputSpec (com.sap.hadoop.windowing.query2.specification.QueryOutputSpec)2 WindowingException (com.sap.hadoop.windowing.WindowingException)1 Map (java.util.Map)1 Table (org.apache.hadoop.hive.metastore.api.Table)1