Skip to content

Commit

Permalink
Create new helper function instead of modifying 'isValidDecimalValue'
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
  • Loading branch information
mihaibudiu committed May 10, 2024
1 parent e0c65b9 commit 9a6198f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions babel/src/test/resources/sql/redshift.iq
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ EMPNO, EXPR$1
!ok

# SUM
select empno, sum(CAST(comm AS DECIMAL(12, 4))) over (order by empno rows unbounded preceding) from emp where deptno = 30 order by 1;
select empno, sum(comm) over (order by empno rows unbounded preceding) from emp where deptno = 30 order by 1;
EMPNO, EXPR$1
7499, 300.0000
7521, 800.0000
7654, 2200.0000
7698, 2200.0000
7844, 2200.0000
7900, 2200.0000
7499, 300.00
7521, 800.00
7654, 2200.00
7698, 2200.00
7844, 2200.00
7900, 2200.00
!ok

# VAR_POP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ public static boolean isValidDecimalValue(@Nullable BigDecimal value, RelDataTyp
case DECIMAL:
final int intDigits = value.precision() - value.scale();
final int maxIntDigits = toType.getPrecision() - toType.getScale();
return (intDigits <= maxIntDigits) && (value.scale() <= toType.getScale());
return intDigits <= maxIntDigits;
default:
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1909,13 +1909,13 @@ private void checkGroupBySingleSortLimit(boolean approx) {
+ "end as b from \"foodmart\" group by \"store_state\" order by a desc";
final String postAggString = "'postAggregations':[{'type':'expression','name':'A',"
+ "'expression':'(\\'$f1\\' / \\'$f2\\')'},{'type':'expression','name':'B',"
+ "'expression':'case_searched((\\'$f3\\' == 0),1,CAST(\\'$f3\\'";
+ "'expression':'case_searched((\\'$f3\\' == 0),1.0,CAST(\\'$f3\\'";
final String plan = "PLAN="
+ "EnumerableInterpreter\n"
+ " DruidQuery(table=[[foodmart, foodmart]],"
+ " intervals=[[1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z]],"
+ " projects=[[$63, $90, $91, $89]], groups=[{0}], aggs=[[SUM($1), SUM($2), SUM($3)]],"
+ " post_projects=[[$0, /($1, $2), CASE(=($3, 0), CAST(1:DECIMAL(19, 0)):DECIMAL(19, 0),"
+ " post_projects=[[$0, /($1, $2), CASE(=($3, 0), 1.0:DECIMAL(19, 0),"
+ " CAST($3):DECIMAL(19, 0))]], sort0=[1], dir0=[DESC])\n";
CalciteAssert.AssertQuery q = sql(sqlQuery)
.explainContains(plan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2215,12 +2215,12 @@ private void checkGroupBySingleSortLimit(boolean approx) {
+ "from \"foodmart\" group by \"store_state\" order by a desc";
final String postAggString = "'postAggregations':[{'type':'expression','name':'A',"
+ "'expression':'(\\'$f1\\' / \\'$f2\\')'},{'type':'expression','name':'B',"
+ "'expression':'case_searched((\\'$f3\\' == 0),1,CAST(\\'$f3\\'";
+ "'expression':'case_searched((\\'$f3\\' == 0),1.0,CAST(\\'$f3\\'";
final String plan =
"DruidQuery(table=[[foodmart, foodmart]], intervals=[[1900-01-09T00:00:00.000Z/"
+ "2992-01-10T00:00:00.000Z]], projects=[[$63, $90, $91, $89]], groups=[{0}], "
+ "aggs=[[SUM($1), SUM($2), SUM($3)]], post_projects=[[$0, /($1, $2), "
+ "CASE(=($3, 0), CAST(1:DECIMAL(19, 0)):DECIMAL(19, 0), "
+ "CASE(=($3, 0), 1.0:DECIMAL(19, 0), "
+ "CAST($3):DECIMAL(19, 0))]], sort0=[1], dir0=[DESC])";
CalciteAssert.AssertQuery q = sql(sqlQuery, FOODMART)
.explainContains(plan)
Expand Down

0 comments on commit 9a6198f

Please sign in to comment.