From a44af65812086c6e692e42c783e89cf54e5d1cd9 Mon Sep 17 00:00:00 2001 From: "peng.jianhua" Date: Fri, 9 Feb 2018 16:01:51 +0800 Subject: [PATCH 1/1] kylin-3119 add more test cases with enter and space --- .../org/apache/kylin/query/util/QueryUtilTest.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java b/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java index e3cd819bf..c5850d7b5 100644 --- a/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java +++ b/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java @@ -51,6 +51,58 @@ public class QueryUtilTest extends LocalFileMetadataTestCase { "select ( date '2001-09-28' + interval '2' month) from test_kylin_fact group by ( date '2001-09-28' + interval '2' month)", s); } + { + String sql = "select count(*) test_limit from test_kylin_fact where price > 10.0"; + String s = QueryUtil.massageSql(sql, "default", 50000, 0, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_limit from test_kylin_fact where price > 10.0\n" + + "LIMIT 50000", + s); + } + { + String sql = "select count(*) test_offset from test_kylin_fact where price > 10.0"; + String s = QueryUtil.massageSql(sql, "default", 0, 50, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_offset from test_kylin_fact where price > 10.0\n" + + "OFFSET 50", + s); + } + { + String sql = "select count(*) test_limit_and_offset from test_kylin_fact where price > 10.0"; + String s = QueryUtil.massageSql(sql, "default", 50000, 50, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_limit_and_offset from test_kylin_fact where price > 10.0\n" + + "LIMIT 50000\nOFFSET 50", + s); + } + + { + String newLine = System.getProperty("line.separator"); + String sql = "select count(*) test_limit from " + newLine + "test_kylin_fact where price > 10.0"; + newLine = newLine.replace("\r", " ").replace("\n", newLine); + String s = QueryUtil.massageSql(sql, "default", 50000, 0, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_limit from " + newLine + "test_kylin_fact where price > 10.0\nLIMIT 50000", + s); + } + { + String newLine = System.getProperty("line.separator"); + String sql = "select count(*) test_offset from " + newLine + "test_kylin_fact where price > 10.0"; + newLine = newLine.replace("\r", " ").replace("\n", newLine); + String s = QueryUtil.massageSql(sql, "default", 50000, 0, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_offset from " + newLine + "test_kylin_fact where price > 10.0\nLIMIT 50000", + s); + } + { + String newLine = System.getProperty("line.separator"); + String sql = "select count(*) test_limit_and_offset from " + newLine + "test_kylin_fact where price > 10.0"; + newLine = newLine.replace("\r", " ").replace("\n", newLine); + String s = QueryUtil.massageSql(sql, "default", 50000, 0, "DEFAULT"); + Assert.assertEquals( + "select count(*) test_limit_and_offset from " + newLine + "test_kylin_fact where price > 10.0\nLIMIT 50000", + s); + } } @Test -- 2.11.0.windows.1