Search in sources :

Example 6 with PartitionDef

use of com.sap.hadoop.windowing.query2.definition.PartitionDef in project SQLWindowing by hbutani.

the class PTFOperator method setupKeysWrapper.

protected void setupKeysWrapper(ObjectInspector inputOI) throws HiveException {
    PartitionDef pDef = RuntimeUtils.getFirstTableFunction(qDef).getWindow().getPartDef();
    ArrayList<ColumnDef> cols = pDef.getColumns();
    int numCols = cols.size();
    ExprNodeEvaluator[] keyFields = new ExprNodeEvaluator[numCols];
    ObjectInspector[] keyOIs = new ObjectInspector[numCols];
    ObjectInspector[] currentKeyOIs = new ObjectInspector[numCols];
    for (int i = 0; i < numCols; i++) {
        ColumnDef cDef = cols.get(i);
        /*
			 * Why cannot we just use the ExprNodeEvaluator on the column?
			 * - because on the reduce-side it is initialized based on the rowOI of the HiveTable 
			 *   and not the OI of the ExtractOp ( the parent of this Operator on the reduce-side)
			 */
        keyFields[i] = ExprNodeEvaluatorFactory.get(cDef.getExprNode());
        keyOIs[i] = keyFields[i].initialize(inputOI);
        currentKeyOIs[i] = ObjectInspectorUtils.getStandardObjectInspector(keyOIs[i], ObjectInspectorCopyOption.WRITABLE);
    }
    keyWrapperFactory = new WindowingKeyWrapperFactory(keyFields, keyOIs, currentKeyOIs);
    newKeys = keyWrapperFactory.getWindowingKeyWrapper();
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) PartitionDef(com.sap.hadoop.windowing.query2.definition.PartitionDef) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) ColumnDef(com.sap.hadoop.windowing.query2.definition.ColumnDef)

Aggregations

PartitionDef (com.sap.hadoop.windowing.query2.definition.PartitionDef)5 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)4 OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)4 OrderColumnDef (com.sap.hadoop.windowing.query2.definition.OrderColumnDef)3 WindowingException (com.sap.hadoop.windowing.WindowingException)2 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)2 WindowFrameDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef)2 OrderColumnSpec (com.sap.hadoop.windowing.query2.specification.OrderColumnSpec)2 ColumnSpec (com.sap.hadoop.windowing.query2.specification.ColumnSpec)1 OrderSpec (com.sap.hadoop.windowing.query2.specification.OrderSpec)1 PartitionSpec (com.sap.hadoop.windowing.query2.specification.PartitionSpec)1 QuerySpec (com.sap.hadoop.windowing.query2.specification.QuerySpec)1 WindowFrameSpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)1 ArrayList (java.util.ArrayList)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1