|
18 | 18 |
|
19 | 19 | package org.apache.flink.table.planner.runtime.stream.sql |
20 | 20 |
|
| 21 | +import org.apache.flink.api.java.typeutils.RowTypeInfo |
21 | 22 | import org.apache.flink.api.scala._ |
22 | 23 | import org.apache.flink.table.api._ |
23 | 24 | import org.apache.flink.table.api.bridge.scala._ |
24 | 25 | import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.StateBackendMode |
25 | 26 | import org.apache.flink.table.planner.runtime.utils.TimeTestUtil.EventTimeProcessOperator |
26 | 27 | import org.apache.flink.table.planner.runtime.utils.UserDefinedFunctionTestUtils.{CountNullNonNull, CountPairs, LargerThanCount} |
27 | 28 | import org.apache.flink.table.planner.runtime.utils.{StreamingWithStateTestBase, TestData, TestingAppendSink} |
| 29 | +import org.apache.flink.table.runtime.typeutils.BigDecimalTypeInfo |
28 | 30 | import org.apache.flink.types.Row |
29 | 31 |
|
30 | 32 | import org.junit.Assert._ |
31 | 33 | import org.junit._ |
32 | 34 | import org.junit.runner.RunWith |
33 | 35 | import org.junit.runners.Parameterized |
34 | | - |
35 | 36 | import scala.collection.mutable |
36 | 37 |
|
37 | 38 | @RunWith(classOf[Parameterized]) |
@@ -1131,4 +1132,33 @@ class OverAggregateITCase(mode: StateBackendMode) extends StreamingWithStateTest |
1131 | 1132 | "B,Hello World,10,7") |
1132 | 1133 | assertEquals(expected, sink.getAppendResults) |
1133 | 1134 | } |
| 1135 | + |
| 1136 | + @Test |
| 1137 | + def testDecimalSum0(): Unit = { |
| 1138 | + val data = new mutable.MutableList[Row] |
| 1139 | + data.+=(Row.of(BigDecimal(1.11).bigDecimal)) |
| 1140 | + data.+=(Row.of(BigDecimal(2.22).bigDecimal)) |
| 1141 | + data.+=(Row.of(BigDecimal(3.33).bigDecimal)) |
| 1142 | + data.+=(Row.of(BigDecimal(4.44).bigDecimal)) |
| 1143 | + |
| 1144 | + env.setParallelism(1) |
| 1145 | + val rowType = new RowTypeInfo(BigDecimalTypeInfo.of(38, 18)) |
| 1146 | + val t = failingDataSource(data)(rowType).toTable(tEnv, 'd, 'proctime.proctime) |
| 1147 | + tEnv.registerTable("T", t) |
| 1148 | + |
| 1149 | + val sqlQuery = "select sum(d) over (ORDER BY proctime rows between unbounded preceding " + |
| 1150 | + "and current row) from T" |
| 1151 | + |
| 1152 | + val result = tEnv.sqlQuery(sqlQuery).toAppendStream[Row] |
| 1153 | + val sink = new TestingAppendSink |
| 1154 | + result.addSink(sink) |
| 1155 | + env.execute() |
| 1156 | + |
| 1157 | + val expected = List( |
| 1158 | + "1.110000000000000000", |
| 1159 | + "3.330000000000000000", |
| 1160 | + "6.660000000000000000", |
| 1161 | + "11.100000000000000000") |
| 1162 | + assertEquals(expected, sink.getAppendResults) |
| 1163 | + } |
1134 | 1164 | } |
0 commit comments