mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #908 from wenshao/master
change case when output format
This commit is contained in:
@@ -203,7 +203,10 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
println();
|
||||
}
|
||||
|
||||
printAndAccept(x.getItems(), " ");
|
||||
for (int i = 0, size = x.getItems().size(); i < size; ++i) {
|
||||
println();
|
||||
x.getItems().get(i).accept(this);
|
||||
}
|
||||
|
||||
if (x.getElseExpr() != null) {
|
||||
println();
|
||||
@@ -211,9 +214,10 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
x.getElseExpr().accept(this);
|
||||
}
|
||||
|
||||
decrementIndent();
|
||||
println();
|
||||
print("END");
|
||||
decrementIndent();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.alibaba.druid.bvt.sql.odps;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class OdpsCaseWhenTest extends TestCase {
|
||||
|
||||
public void test_if() throws Exception {
|
||||
String sql = "select case when f1 = 'aaa' then 1 when f1 = 'bbb' then 2 else 3 end from dual";
|
||||
Assert.assertEquals("SELECT CASE "
|
||||
+ "\n\t\tWHEN f1 = 'aaa' THEN 1"
|
||||
+ "\n\t\tWHEN f1 = 'bbb' THEN 2"
|
||||
+ "\n\t\tELSE 3"
|
||||
+ "\n\tEND"
|
||||
+ "\nFROM dual", SQLUtils.formatOdps(sql));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user