Java Code Examples for com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadDataInFileStatement#getColumnsEscaped()
The following examples show how to use
com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadDataInFileStatement#getColumnsEscaped() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbleOutputVisitor.java From dble with GNU General Public License v2.0 | 6 votes |
private void columnsParameter(MySqlLoadDataInFileStatement x) { if (x.getColumnsTerminatedBy() != null || x.getColumnsEnclosedBy() != null || x.getColumnsEscaped() != null) { print0(ucase ? " COLUMNS" : " columns"); if (x.getColumnsTerminatedBy() != null) { print0(ucase ? " TERMINATED BY " : " terminated by "); x.getColumnsTerminatedBy().accept(this); } if (x.getColumnsEnclosedBy() != null) { if (x.isColumnsEnclosedOptionally()) { print0(ucase ? " OPTIONALLY" : " optionally"); } print0(ucase ? " ENCLOSED BY " : " enclosed by "); x.getColumnsEnclosedBy().accept(this); } if (x.getColumnsEscaped() != null) { print0(ucase ? " ESCAPED BY " : " escaped by "); x.getColumnsEscaped().accept(this); } } }
Example 2
Source File: HintDataNodeHandler.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
private LoadData parseLoadDataPram(String sql , String connectionCharset) { SQLStatementParser parser = new MycatStatementParser(sql); MySqlLoadDataInFileStatement statement = (MySqlLoadDataInFileStatement) parser.parseStatement(); LoadData loadData = new LoadData(); SQLTextLiteralExpr rawLineEnd = (SQLTextLiteralExpr) statement.getLinesTerminatedBy(); String lineTerminatedBy = rawLineEnd == null ? "\n" : rawLineEnd.getText(); loadData.setLineTerminatedBy(lineTerminatedBy); SQLTextLiteralExpr rawFieldEnd = (SQLTextLiteralExpr) statement.getColumnsTerminatedBy(); String fieldTerminatedBy = rawFieldEnd == null ? "\t" : rawFieldEnd.getText(); loadData.setFieldTerminatedBy(fieldTerminatedBy); SQLTextLiteralExpr rawEnclosed = (SQLTextLiteralExpr) statement.getColumnsEnclosedBy(); String enclose = rawEnclosed == null ? null : rawEnclosed.getText(); loadData.setEnclose(enclose); SQLTextLiteralExpr escapseExpr = (SQLTextLiteralExpr)statement.getColumnsEscaped() ; String escapse=escapseExpr==null?"\\":escapseExpr.getText(); loadData.setEscape(escapse); String charset = statement.getCharset() != null ? statement.getCharset() : connectionCharset; loadData.setCharset(charset); String fileName = parseFileName(sql); if(StringUtils.isBlank(fileName)){ throw new RuntimeException(" file name is null !"); } loadData.setFileName(fileName); return loadData ; }
Example 3
Source File: LoadDataOutputVisitor.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean visit(MySqlLoadDataInFileStatement x) { print("LOAD DATA "); if (x.isLowPriority()) { print("LOW_PRIORITY "); } if (x.isConcurrent()) { print("CONCURRENT "); } if (x.isLocal()) { print("LOCAL "); } print("INFILE "); x.getFileName().accept(this); if (x.isReplicate()) { print(" REPLACE "); } if (x.isIgnore()) { print(" IGNORE "); } print(" INTO TABLE "); x.getTableName().accept(this); if(x.getCharset()!=null) { print(" CHARACTER SET "); print("'"+x.getCharset()+"'"); } if (x.getColumnsTerminatedBy() != null || x.getColumnsEnclosedBy() != null || x.getColumnsEscaped() != null) { print(" COLUMNS"); if (x.getColumnsTerminatedBy() != null) { print(" TERMINATED BY "); x.getColumnsTerminatedBy().accept(this); } if (x.getColumnsEnclosedBy() != null) { if (x.isColumnsEnclosedOptionally()) { print(" OPTIONALLY"); } print(" ENCLOSED BY "); x.getColumnsEnclosedBy().accept(this); } if (x.getColumnsEscaped() != null) { print(" ESCAPED BY "); x.getColumnsEscaped().accept(this); } } if (x.getLinesStartingBy() != null || x.getLinesTerminatedBy() != null) { print(" LINES"); if (x.getLinesStartingBy() != null) { print(" STARTING BY "); x.getLinesStartingBy().accept(this); } if (x.getLinesTerminatedBy() != null) { print(" TERMINATED BY "); x.getLinesTerminatedBy().accept(this); } } if(x.getIgnoreLinesNumber() != null) { print(" IGNORE "); x.getIgnoreLinesNumber().accept(this); print(" LINES"); } if (x.getColumns().size() != 0) { print(" ("); printAndAccept(x.getColumns(), ", "); print(")"); } if (x.getSetList().size() != 0) { print(" SET "); printAndAccept(x.getSetList(), ", "); } return false; }