@Override public void visit(WindowSpecification windowSpecification) { visitNodes(windowSpecification.getPartition()); visitNode(windowSpecification.getOrderBy()); visitNode(windowSpecification.getWindowFrame()); }
org.teiid.language.WindowFunction translate(WindowFunction windowFunction) { org.teiid.language.WindowFunction result = new org.teiid.language.WindowFunction(); result.setFunction(translate(windowFunction.getFunction())); WindowSpecification ws = new WindowSpecification(); ws.setOrderBy(translate(windowFunction.getWindowSpecification().getOrderBy(), false)); List<Expression> partition = windowFunction.getWindowSpecification().getPartition(); if (partition != null) { ArrayList<org.teiid.language.Expression> partitionList = translateExpressionList(partition); ws.setPartition(partitionList); } WindowFrame frame = windowFunction.getWindowSpecification().getWindowFrame(); if (frame != null) { org.teiid.language.WindowFrame resultFrame = new org.teiid.language.WindowFrame(frame.getMode()); resultFrame.setStart(translate(frame.getStart())); resultFrame.setEnd(translate(frame.getEnd())); ws.setWindowFrame(resultFrame); } result.setWindowSpecification(ws); return result; }
org.teiid.language.WindowFunction translate(WindowFunction windowFunction) { org.teiid.language.WindowFunction result = new org.teiid.language.WindowFunction(); result.setFunction(translate(windowFunction.getFunction())); WindowSpecification ws = new WindowSpecification(); ws.setOrderBy(translate(windowFunction.getWindowSpecification().getOrderBy(), false)); List<Expression> partition = windowFunction.getWindowSpecification().getPartition(); if (partition != null) { ArrayList<org.teiid.language.Expression> partitionList = translateExpressionList(partition); ws.setPartition(partitionList); } result.setWindowSpecification(ws); return result; }
expression.setFunction(new AggregateFunction("ROW_NUMBER", //$NON-NLS-1$ false, Collections.EMPTY_LIST, TypeFacility.RUNTIME_TYPES.INTEGER)); WindowSpecification windowSpecification = new WindowSpecification(); windowSpecification.setOrderBy(orderBy); expression.setWindowSpecification(windowSpecification); select.getDerivedColumns().add(new DerivedColumn("ROWNUM_", expression)); //$NON-NLS-1$
org.teiid.language.WindowFunction translate(WindowFunction windowFunction) { org.teiid.language.WindowFunction result = new org.teiid.language.WindowFunction(); result.setFunction(translate(windowFunction.getFunction())); WindowSpecification ws = new WindowSpecification(); ws.setOrderBy(translate(windowFunction.getWindowSpecification().getOrderBy(), false)); List<Expression> partition = windowFunction.getWindowSpecification().getPartition(); if (partition != null) { ArrayList<org.teiid.language.Expression> partitionList = translateExpressionList(partition); ws.setPartition(partitionList); } WindowFrame frame = windowFunction.getWindowSpecification().getWindowFrame(); if (frame != null) { org.teiid.language.WindowFrame resultFrame = new org.teiid.language.WindowFrame(frame.getMode()); resultFrame.setStart(translate(frame.getStart())); resultFrame.setEnd(translate(frame.getEnd())); ws.setWindowFrame(resultFrame); } result.setWindowSpecification(ws); return result; }
@Override public void visit(WindowSpecification windowSpecification) { buffer.append(Tokens.LPAREN); boolean needsSpace = false; if (windowSpecification.getPartition() != null) { buffer.append(PARTITION); buffer.append(Tokens.SPACE); buffer.append(BY); buffer.append(Tokens.SPACE); append(windowSpecification.getPartition()); needsSpace = true; } if (windowSpecification.getOrderBy() != null) { if (needsSpace) { buffer.append(Tokens.SPACE); } append(windowSpecification.getOrderBy()); needsSpace = true; } if (windowSpecification.getWindowFrame() != null) { if (needsSpace) { buffer.append(Tokens.SPACE); } append(windowSpecification.getWindowFrame()); } buffer.append(Tokens.RPAREN); }