Merge pull request #929 from wenshao/master

improved odps sql formatter
This commit is contained in:
高铁
2015-08-05 16:32:47 +08:00
3 changed files with 5 additions and 4 deletions
@@ -350,9 +350,9 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
x.getRight().accept(this);
if (x.getCondition() != null) {
incrementIndent();
println();
print("ON ");
incrementIndent();
x.getCondition().accept(this);
decrementIndent();
}
@@ -12,7 +12,7 @@ public class OdpsFormatCommentTest20 extends TestCase {
Assert.assertEquals("SELECT *"
+ "\nFROM a"
+ "\nFULL OUTER JOIN b"
+ "\n\tON a.id = b.id", SQLUtils.formatOdps(sql));
+ "\nON a.id = b.id", SQLUtils.formatOdps(sql));
}
@@ -29,13 +29,14 @@ public class OdpsSelectTest_mapjoin extends TestCase {
+ "\nb.customer_id,"
+ "\nb.total_price"
+ "\nfrom shop a join sale_detail b"
+ "\non a.shop_name = b.shop_name;";
+ "\non a.shop_name = b.shop_name and b.ds = '20150101';";
Assert.assertEquals("SELECT /*+ mapjoin(a) */ a.shop_name"
+ "\n\t, b.customer_id"
+ "\n\t, b.total_price"
+ "\nFROM shop a"
+ "\nJOIN sale_detail b"
+ "\n\tON a.shop_name = b.shop_name;", SQLUtils.formatOdps(sql));
+ "\nON a.shop_name = b.shop_name"
+ "\n\tAND b.ds = '20150101';", SQLUtils.formatOdps(sql));
}