Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
Signed-off-by: packy92 <wangchao@starrocks.com>
  • Loading branch information
packy92 committed Jul 2, 2024
1 parent 286b7a8 commit 46a1bb4
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public void test() throws Exception {
plan = getFragmentPlan(sql);
assertContains(plan, "functions: [, ntile(1), ]");

sql = "select /*+ set_user_variable(@a = 1, @b = 10) */ percentile_approx(v1, @a) from t0";
plan = getFragmentPlan(sql);
assertContains(plan, "percentile_approx(CAST(1: v1 AS DOUBLE), 1.0)");

Exception exception = Assert.assertThrows(SemanticException.class, () -> {
String invalidSql = "select /*+ set_user_variable(@a = 1, @b = 1000000) */ APPROX_TOP_K(v1, @a), " +
Expand All @@ -110,5 +113,11 @@ public void test() throws Exception {
getFragmentPlan(invalidSql);
});
assertContains(exception.getMessage(), "The offset parameter of LEAD/LAG must be a constant positive integer");

exception = Assert.assertThrows(SemanticException.class, () -> {
String invalidSql = "select /*+ set_user_variable(@a = 1, @b = 10) */ percentile_approx(@a, @b) from t0";
getFragmentPlan(invalidSql);
});
assertContains(exception.getMessage(), " percentile_approx second parameter'value must be between 0 and 1");
}
}

0 comments on commit 46a1bb4

Please sign in to comment.