mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser for odps show tables
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.alibaba.druid.bvt.sql.odps;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class OdpsShowTablesTest0 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "show tables";
|
||||
OdpsStatementParser parser = new OdpsStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toOdpsString(stmt);
|
||||
Assert.assertEquals("SHOW TABLES", output);
|
||||
}
|
||||
|
||||
public void test_from() throws Exception {
|
||||
String sql = "show tables from xx";
|
||||
OdpsStatementParser parser = new OdpsStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toOdpsString(stmt);
|
||||
Assert.assertEquals("SHOW TABLES FROM xx", output);
|
||||
}
|
||||
|
||||
public void test_from_like() throws Exception {
|
||||
String sql = "show tables from xx like '*'";
|
||||
OdpsStatementParser parser = new OdpsStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toOdpsString(stmt);
|
||||
Assert.assertEquals("SHOW TABLES FROM xx LIKE '*'", output);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user