improved odps support

This commit is contained in:
shaojin.wensj
2015-07-30 13:22:13 +08:00
parent 9d45ec9d12
commit eb7b7037c4
12 changed files with 260 additions and 68 deletions
@@ -18,6 +18,7 @@ public class OdpsCreateTableTest2 extends TestCase {
parser.match(Token.EOF);
String output = SQLUtils.toOdpsString(stmt);
Assert.assertEquals("CREATE TABLE sale_detail"
+ "\nAS"
+ "\nSELECT *" //
+ "\nFROM dual", output);
}
@@ -0,0 +1,18 @@
package com.alibaba.druid.bvt.sql.odps;
import org.junit.Assert;
import com.alibaba.druid.sql.SQLUtils;
import junit.framework.TestCase;
public class OdpsFormatCommentTest23 extends TestCase {
public void test_drop_table() throws Exception {
String sql = "-- xxx"
+ "\n -- yyy"
+ "\ndrop table if exists mytables;";
Assert.assertEquals("-- xxx"
+ "\n-- yyy"
+ "\nDROP TABLE IF EXISTS mytables;", SQLUtils.formatOdps(sql));
}
}
@@ -0,0 +1,18 @@
package com.alibaba.druid.bvt.sql.odps;
import org.junit.Assert;
import com.alibaba.druid.sql.SQLUtils;
import junit.framework.TestCase;
public class OdpsFormatCommentTest24 extends TestCase {
public void test_drop_view() throws Exception {
String sql = "-- xxx"
+ "\n -- yyy"
+ "\ndrop view if exists mytables;";
Assert.assertEquals("-- xxx"
+ "\n-- yyy"
+ "\nDROP VIEW IF EXISTS mytables;", SQLUtils.formatOdps(sql));
}
}
@@ -0,0 +1,18 @@
package com.alibaba.druid.bvt.sql.odps;
import org.junit.Assert;
import com.alibaba.druid.sql.SQLUtils;
import junit.framework.TestCase;
public class OdpsFormatCommentTest25 extends TestCase {
public void test_drop_function() throws Exception {
String sql = "-- xxx"
+ "\n -- yyy"
+ "\ndrop function if exists mytables;";
Assert.assertEquals("-- xxx"
+ "\n-- yyy"
+ "\nDROP FUNCTION IF EXISTS mytables;", SQLUtils.formatOdps(sql));
}
}
@@ -0,0 +1,17 @@
package com.alibaba.druid.bvt.sql.odps;
import org.junit.Assert;
import com.alibaba.druid.sql.SQLUtils;
import junit.framework.TestCase;
public class OdpsFormatCommentTest26 extends TestCase {
public void test_drop_function() throws Exception {
String sql = "create table t as select * from dual;";
Assert.assertEquals("CREATE TABLE t"
+ "\nAS"
+ "\nSELECT *"
+ "\nFROM dual;", SQLUtils.formatOdps(sql));
}
}