UnparseUtil node(SqlNode n) { n.unparse(writer, leftPrec, rightPrec); return this; }
@Override public void writeWith(SqlCall call, int leftPrec, int rightPrec) { final SqlWith with = (SqlWith) call; final SqlWriter.Frame frame = this.startList(SqlWriter.FrameTypeEnum.WITH, "WITH", ""); for (SqlNode node : with.withList) { this.sep(","); node.unparse(this, 0, 0); } with.body.unparse(this, 100, 100); this.endList(frame); }
@Override public void unparse( SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { List<SqlNode> opList = call.getOperandList(); assert (opList.size() >= 1); SqlNode sqlNode = opList.get(0); sqlNode.unparse(writer, leftPrec, getLeftPrec()); writer.sep("IN"); Frame frame = writer.startList(FrameTypeEnum.SETOP, "(", ")"); for (SqlNode op : opList.subList(1, opList.size())) { writer.sep(","); op.unparse(writer, 0, 0); } writer.endList(frame); } }
private void doWriteLimitOffset(SqlNode fetch, SqlNode offset) { // Dialect does not support OFFSET/FETCH clause. // Assume it uses LIMIT/OFFSET. if (fetch != null) { this.newlineAndIndent(); final Frame fetchFrame = this.startList(FrameTypeEnum.FETCH); this.keyword("LIMIT"); fetch.unparse(this, -1, -1); this.endList(fetchFrame); } if (offset != null) { this.newlineAndIndent(); final Frame offsetFrame = this.startList(FrameTypeEnum.OFFSET); this.keyword("OFFSET"); offset.unparse(this, -1, -1); this.endList(offsetFrame); } }
@Override public void writeWithItem(SqlCall call, SqlWithItem.SqlWithItemOperator sqlWithItemOperator, int leftPrec, int rightPrec) { final SqlWithItem withItem = (SqlWithItem) call; leftPrec = sqlWithItemOperator.getLeftPrec(); rightPrec = sqlWithItemOperator.getRightPrec(); withItem.name.unparse(this, leftPrec, rightPrec); if (withItem.columnList != null) { withItem.columnList.unparse(this, leftPrec, rightPrec); } this.keyword("AS"); Frame frame = this.startList(FrameTypeEnum.WITH_ITEM, "(", ")"); withItem.query.unparse(this, 10, 10); this.endList(frame); } }
UnparseUtil node(SqlNode n) { n.unparse(writer, leftPrec, rightPrec); return this; }
private void doWriteFetchNext(SqlNode fetch, SqlNode offset) { if (offset == null && !configurer.allowNoOffset()) offset = SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO); if (fetch != null && !configurer.allowNoOrderByWithFetch() && lastFrame != null && lastFrame.getFrameType() != FrameTypeEnum.ORDER_BY_LIST) { // MSSQL requires ORDER_BY list for FETCH clause, so must append one here. DUMMY_ORDER_BY_NODE.unparse(this, 0, 0); } if (offset != null) { this.newlineAndIndent(); final Frame offsetFrame = this.startList(FrameTypeEnum.OFFSET); this.keyword("OFFSET"); offset.unparse(this, -1, -1); this.keyword("ROWS"); this.endList(offsetFrame); } if (fetch != null) { if (!configurer.allowFetchNoRows() && fetch instanceof SqlNumericLiteral) if (((SqlNumericLiteral) fetch).toValue().equals("0")) fetch = SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO); this.newlineAndIndent(); final Frame fetchFrame = this.startList(FrameTypeEnum.FETCH); this.keyword("FETCH"); this.keyword("NEXT"); fetch.unparse(this, -1, -1); this.keyword("ROWS"); this.keyword("ONLY"); this.endList(fetchFrame); } }
void commaList(SqlWriter writer) { // The precedence of the comma operator if low but not zero. For // instance, this ensures parentheses in // select x, (select * from foo order by z), y from t for (SqlNode node : list) { writer.sep(","); node.unparse(writer, 2, 3); } }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { writer.keyword("SHOW"); writer.keyword("SCHEMAS"); if (likePattern != null) { writer.keyword("LIKE"); likePattern.unparse(writer, leftPrec, rightPrec); } if (whereClause != null) { whereClause.unparse(writer, leftPrec, rightPrec); } }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { writer.sep(kind == SqlKind.NEXT_VALUE ? "NEXT VALUE FOR" : "CURRENT VALUE FOR"); call.getOperandList().get(0).unparse(writer, 0, 0); }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startList(SqlWriter.FrameTypeEnum.IDENTIFIER); call.operand(0).unparse(writer, leftPrec, 0); writer.sep("."); call.operand(1).unparse(writer, 0, 0); writer.endList(frame); }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startFunCall(getName()); if (call.operandCount() == 2) { call.operand(0).unparse(writer, 0, 100); writer.sep("TO"); call.operand(1).unparse(writer, 100, 0); } else { call.operand(0).unparse(writer, 0, 0); } writer.endFunCall(frame); }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { writer.keyword("SHOW"); writer.keyword("TABLES"); if (db != null) { db.unparse(writer, leftPrec, rightPrec); } if (likePattern != null) { writer.keyword("LIKE"); likePattern.unparse(writer, leftPrec, rightPrec); } }
public void unparse( SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startFunCall(getName()); call.operand(0).unparse(writer, 0, 0); writer.endFunCall(frame); } }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { writer.startList(SqlWriter.FrameTypeEnum.SELECT); writer.sep(isUpsert() ? "UPSERT INTO" : "INSERT INTO"); final int opLeft = getOperator().getLeftPrec(); final int opRight = getOperator().getRightPrec(); targetTable.unparse(writer, opLeft, opRight); if (columnList != null) { columnList.unparse(writer, opLeft, opRight); } writer.newlineAndIndent(); source.unparse(writer, 0, 0); }
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { if (call.operandCount() == 1 && call.getOperandList().get(0).getKind() == SqlKind.COLLECTION_TABLE) { // do not create ( ) around the following TABLE clause writer.keyword(getName()); call.operand(0).unparse(writer, 0, 0); } else { SqlUtil.unparseFunctionSyntax(this, writer, call); } } }
public void unparse( SqlWriter writer, SqlOperator operator, SqlCall call, int leftPrec, int rightPrec) { assert call.operandCount() == 1; call.operand(0).unparse(writer, operator.getLeftPrec(), operator.getRightPrec()); writer.keyword(operator.getName()); } },
@Override protected void unparseAlterOperation(SqlWriter writer, int leftPrec, int rightPrec) { writer.keyword("UPLOAD"); writer.keyword("JAR"); SqlWriter.Frame frame = writer.startList("", ""); for (SqlNode jarPath : jarPaths) { jarPath.unparse(writer, leftPrec, rightPrec); } writer.endList(frame); } }