use of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitionSpec in project hive by apache.
the class SemanticAnalyzer method processPTFPartitionSpec.
private PartitioningSpec processPTFPartitionSpec(ASTNode pSpecNode) {
PartitioningSpec partitioning = new PartitioningSpec();
ASTNode firstChild = (ASTNode) pSpecNode.getChild(0);
int type = firstChild.getType();
if (type == HiveParser.TOK_DISTRIBUTEBY || type == HiveParser.TOK_CLUSTERBY) {
PartitionSpec pSpec = processPartitionSpec(firstChild);
partitioning.setPartSpec(pSpec);
ASTNode sortNode = pSpecNode.getChildCount() > 1 ? (ASTNode) pSpecNode.getChild(1) : null;
if (sortNode != null) {
OrderSpec oSpec = processOrderSpec(sortNode);
partitioning.setOrderSpec(oSpec);
}
} else if (type == HiveParser.TOK_SORTBY || type == HiveParser.TOK_ORDERBY) {
OrderSpec oSpec = processOrderSpec(firstChild);
partitioning.setOrderSpec(oSpec);
}
return partitioning;
}
use of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitionSpec in project hive by apache.
the class PTFTranslator method applyConstantPartition.
/*
* If this the first PPTF in the chain and there is no partition specified
* then assume the user wants to include the entire input in 1 partition.
*/
private static void applyConstantPartition(PartitionedTableFunctionSpec spec) {
if (spec.getPartition() != null) {
return;
}
PTFInputSpec iSpec = spec.getInput();
if (iSpec instanceof PTFInputSpec) {
PartitionSpec partSpec = new PartitionSpec();
PartitionExpression partExpr = new PartitionExpression();
partExpr.setExpression(new ASTNode(new CommonToken(HiveParser.Number, "0")));
partSpec.addExpression(partExpr);
spec.setPartition(partSpec);
}
}
use of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitionSpec in project hive by apache.
the class WindowingSpec method applyConstantPartition.
private void applyConstantPartition(WindowSpec wdwSpec) {
PartitionSpec partSpec = wdwSpec.getPartition();
if (partSpec == null) {
partSpec = new PartitionSpec();
PartitionExpression partExpr = new PartitionExpression();
partExpr.setExpression(new ASTNode(new CommonToken(HiveParser.Number, "0")));
partSpec.addExpression(partExpr);
wdwSpec.setPartition(partSpec);
}
}
use of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitionSpec in project hive by apache.
the class ExprNodeConverter method getPSpec.
private PartitioningSpec getPSpec(RexWindow window) {
PartitioningSpec partitioning = new PartitioningSpec();
Schema schema = new Schema(tabAlias, inputRowType.getFieldList());
if (window.partitionKeys != null && !window.partitionKeys.isEmpty()) {
PartitionSpec pSpec = new PartitionSpec();
for (RexNode pk : window.partitionKeys) {
PartitionExpression exprSpec = new PartitionExpression();
ASTNode astNode = pk.accept(new RexVisitor(schema));
exprSpec.setExpression(astNode);
pSpec.addExpression(exprSpec);
}
partitioning.setPartSpec(pSpec);
}
if (window.orderKeys != null && !window.orderKeys.isEmpty()) {
OrderSpec oSpec = new OrderSpec();
for (RexFieldCollation ok : window.orderKeys) {
OrderExpression exprSpec = new OrderExpression();
Order order = ok.getDirection() == RelFieldCollation.Direction.ASCENDING ? Order.ASC : Order.DESC;
NullOrder nullOrder;
if (ok.right.contains(SqlKind.NULLS_FIRST)) {
nullOrder = NullOrder.NULLS_FIRST;
} else if (ok.right.contains(SqlKind.NULLS_LAST)) {
nullOrder = NullOrder.NULLS_LAST;
} else {
// Default
nullOrder = ok.getDirection() == RelFieldCollation.Direction.ASCENDING ? NullOrder.NULLS_FIRST : NullOrder.NULLS_LAST;
}
exprSpec.setOrder(order);
exprSpec.setNullOrder(nullOrder);
ASTNode astNode = ok.left.accept(new RexVisitor(schema));
exprSpec.setExpression(astNode);
oSpec.addExpression(exprSpec);
}
partitioning.setOrderSpec(oSpec);
}
return partitioning;
}
use of org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitionSpec in project hive by apache.
the class SemanticAnalyzer method processPartitionSpec.
private PartitionSpec processPartitionSpec(ASTNode node) {
PartitionSpec pSpec = new PartitionSpec();
for (Node child : node.getChildren()) {
PartitionExpression exprSpec = new PartitionExpression();
exprSpec.setExpression((ASTNode) child);
pSpec.addExpression(exprSpec);
}
return pSpec;
}
Aggregations