Java Code Examples for com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadDataInFileStatement#isColumnsEnclosedOptionally()

The following examples show how to use com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLoadDataInFileStatement#isColumnsEnclosedOptionally() . 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 vote down vote up
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: LoadDataOutputVisitor.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
@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;
}