Search in sources :

Example 1 with PartitionSpec

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

the class WindowSpecTranslation method translatePartition.

static PartitionDef translatePartition(QueryDef qDef, InputInfo iInfo, PartitionSpec spec) throws WindowingException {
    if (spec == null || spec.getColumns() == null || spec.getColumns().size() == 0)
        return null;
    PartitionDef pDef = new PartitionDef(spec);
    for (ColumnSpec colSpec : spec.getColumns()) {
        ColumnDef cDef = translatePartitionColumn(qDef, iInfo, colSpec);
        pDef.addColumn(cDef);
    }
    return pDef;
}
Also used : OrderColumnSpec(com.sap.hadoop.windowing.query2.specification.OrderColumnSpec) ColumnSpec(com.sap.hadoop.windowing.query2.specification.ColumnSpec) PartitionDef(com.sap.hadoop.windowing.query2.definition.PartitionDef) OrderColumnDef(com.sap.hadoop.windowing.query2.definition.OrderColumnDef) ColumnDef(com.sap.hadoop.windowing.query2.definition.ColumnDef)

Example 2 with PartitionSpec

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

the class WindowSpecTranslation method translateWindowSpecOnInput.

/*
	 * <ol>
	 * <li> If wSpec points to a source WindowSpec. Validate that it is valid. If it hasn't been already translated then translate it.
	 * <li> Start with an empty WdwDef or a cloned WdwDef from the source WdwDef.
	 * <li> translate the PartitionSpec if it exists. Replace the existing PDef with this; also remove the OrderDef.
	 * <li> translate the OrderSpec if it exists. Replace existing OrderDef with this.
	 * <li> add in Partition Columns if not in OrderDef already.
	 * <li> translate the WindowSpec if it exists. Replace existing WdwDef with it.
	 * <li> If name is non-null add this def to TranslationInfo::nameToWdwDef map.
	 * </ol>
	 */
static WindowDef translateWindowSpecOnInput(QueryDef qDef, WindowSpec wSpec, InputInfo iInfo, String inputDesc) throws WindowingException {
    QuerySpec qSpec = qDef.getSpec();
    WindowDef wDef;
    fillInWindowSpec(qSpec, wSpec.getSourceId(), wSpec);
    wDef = new WindowDef(wSpec);
    PartitionSpec pSpec = wSpec.getPartition();
    OrderSpec oSpec = wSpec.getOrder();
    WindowFrameSpec wFrameSpec = wSpec.getWindow();
    PartitionDef pDef = translatePartition(qDef, iInfo, pSpec);
    OrderDef oDef = translateOrder(qDef, inputDesc, iInfo, oSpec, pDef);
    WindowFrameDef wdwDef = translateWindowFrame(qDef, wFrameSpec, iInfo);
    wDef.setPartDef(pDef);
    wDef.setOrderDef(oDef);
    wDef.setWindow(wdwDef);
    return wDef;
}
Also used : OrderSpec(com.sap.hadoop.windowing.query2.specification.OrderSpec) WindowFrameDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef) WindowDef(com.sap.hadoop.windowing.query2.definition.WindowDef) PartitionDef(com.sap.hadoop.windowing.query2.definition.PartitionDef) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec) OrderDef(com.sap.hadoop.windowing.query2.definition.OrderDef) PartitionSpec(com.sap.hadoop.windowing.query2.specification.PartitionSpec) WindowFrameSpec(com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)

Aggregations

PartitionDef (com.sap.hadoop.windowing.query2.definition.PartitionDef)2 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)1 OrderColumnDef (com.sap.hadoop.windowing.query2.definition.OrderColumnDef)1 OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)1 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)1 WindowFrameDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef)1 ColumnSpec (com.sap.hadoop.windowing.query2.specification.ColumnSpec)1 OrderColumnSpec (com.sap.hadoop.windowing.query2.specification.OrderColumnSpec)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