mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps sql formmatter
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.alibaba.druid.bvt.sql.odps;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class OdpsFormatCommentTest22 extends TestCase {
|
||||
public void test_if() throws Exception {
|
||||
String sql = "select if(a>0,1, 0) from dual";
|
||||
Assert.assertEquals("SELECT IF(a > 0, 1, 0)"
|
||||
+ "\nFROM dual", SQLUtils.formatOdps(sql));
|
||||
}
|
||||
|
||||
public void test_coalesce() throws Exception {
|
||||
String sql = "select coalesce(f1,f2) from dual";
|
||||
Assert.assertEquals("SELECT COALESCE(f1, f2)"
|
||||
+ "\nFROM dual", SQLUtils.formatOdps(sql));
|
||||
}
|
||||
public void test_count() throws Exception {
|
||||
String sql = "select count(*) from dual";
|
||||
Assert.assertEquals("SELECT COUNT(*)"
|
||||
+ "\nFROM dual", SQLUtils.formatOdps(sql));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class OdpsIfTest extends TestCase {
|
||||
|
||||
public void test_if() throws Exception {
|
||||
String sql = "select sum(if(a > 0, 1, 0)) from t1";
|
||||
Assert.assertEquals("SELECT SUM(if(a > 0, 1, 0))" //
|
||||
Assert.assertEquals("SELECT SUM(IF(a > 0, 1, 0))" //
|
||||
+ "\nFROM t1", SQLUtils.formatOdps(sql));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user