Search in sources :

Example 1 with OdpsLexer

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer in project druid by alibaba.

the class OdpsLexerTest method test_0.

public void test_0() throws Exception {
    String str = "DESC;";
    OdpsLexer lexer = new OdpsLexer(str);
    lexer.nextToken();
    assertEquals(Token.DESC, lexer.token());
    lexer.nextToken();
    assertEquals(Token.SEMI, lexer.token());
}
Also used : OdpsLexer(com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)

Example 2 with OdpsLexer

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer in project druid by alibaba.

the class OdpsLexerTest method test_1.

public void test_1() throws Exception {
    String str = "——\n" + "\n" + "drop table if exists tdl_idle_mem_portrait_pred_feats_20210831;";
    OdpsLexer lexer = new OdpsLexer(str);
    lexer.nextToken();
    assertEquals(Token.DROP, lexer.token());
}
Also used : OdpsLexer(com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)

Example 3 with OdpsLexer

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer in project druid by alibaba.

the class OdpsLexerTest method test_4.

public void test_4() throws Exception {
    String str = "${PN}_events";
    OdpsLexer lexer = new OdpsLexer(str);
    lexer.nextToken();
    assertEquals(Token.IDENTIFIER, lexer.token());
    assertEquals("${PN}_events", lexer.stringVal());
}
Also used : OdpsLexer(com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)

Example 4 with OdpsLexer

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer in project druid by alibaba.

the class OdpsLexerTest method test_2.

public void test_2() throws Exception {
    String str = "drop table graph_embedding_dev.04_s1_${bizdate}_0108;";
    OdpsLexer lexer = new OdpsLexer(str);
    lexer.nextToken();
    assertEquals(Token.DROP, lexer.token());
    lexer.nextToken();
    assertEquals(Token.TABLE, lexer.token());
    lexer.nextToken();
    assertEquals(Token.IDENTIFIER, lexer.token());
    lexer.nextToken();
    assertEquals(Token.DOT, lexer.token());
    lexer.nextToken();
    assertEquals(Token.IDENTIFIER, lexer.token());
    assertEquals("04_s1_${bizdate}_0108", lexer.stringVal());
}
Also used : OdpsLexer(com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)

Example 5 with OdpsLexer

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer in project druid by alibaba.

the class OdpsLexerTest method test_error_1.

public void test_error_1() throws Exception {
    String str = "`aaa\n${PN}_events";
    OdpsLexer lexer = new OdpsLexer(str);
    int pos = lexer.pos();
    try {
        lexer.nextToken();
    } catch (ParserException error) {
        lexer.skipToNextLineOrParameter(pos);
        lexer.nextToken();
    }
    assertEquals(Token.IDENTIFIER, lexer.token());
    assertEquals("${PN}_events", lexer.stringVal());
}
Also used : ParserException(com.alibaba.druid.sql.parser.ParserException) OdpsLexer(com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)

Aggregations

OdpsLexer (com.alibaba.druid.sql.dialect.odps.parser.OdpsLexer)7 ParserException (com.alibaba.druid.sql.parser.ParserException)2