|
24 | 24 | import java.util.Comparator; |
25 | 25 | import java.util.List; |
26 | 26 | import org.apache.auron.flink.table.AuronFlinkTableTestBase; |
| 27 | +import org.apache.auron.flink.table.planner.UnsupportedFlinkNodeRecorder; |
27 | 28 | import org.apache.flink.types.Row; |
28 | 29 | import org.apache.flink.util.CollectionUtil; |
29 | 30 | import org.junit.jupiter.api.Test; |
@@ -259,6 +260,40 @@ public void testUnixTimestampFixedOffsetTimeZoneFallsBack() { |
259 | 260 | assertThat(rows).isEqualTo(Arrays.asList(Row.of(1602316801L), Row.of(1602316802L), Row.of(1602316803L))); |
260 | 261 | } |
261 | 262 |
|
| 263 | + /** |
| 264 | + * The zero-argument UNIX_TIMESTAMP reads the wall clock rather than parsing a column. It yields |
| 265 | + * one row per input row, each carrying epoch seconds bracketed by the test's own clock reads. |
| 266 | + * |
| 267 | + * <p>Fallback to Flink's codegen Calc is silent and total, and produces an identical row set, so |
| 268 | + * the values alone cannot show the Calc ran natively. The fallback counter narrows it: a Calc |
| 269 | + * that fails to convert always records either an unsupported node or a composition failure |
| 270 | + * before it falls back, so a count of zero means this Calc converted. It does not mean the Calc |
| 271 | + * ran. A native library holding no registry arm for the function still converts at plan time |
| 272 | + * and only fails once executing, where nothing records a fallback, leaving the counter at zero |
| 273 | + * and the result set empty. |
| 274 | + * |
| 275 | + * <p>The row count is what establishes that the native plan executed. {@code allSatisfy} passes |
| 276 | + * vacuously over an empty list, so dropping {@code hasSize(3)} would let that runtime failure |
| 277 | + * read as success and leave native execution unverified. |
| 278 | + */ |
| 279 | + @Test |
| 280 | + public void testUnixTimestampZeroArgRunsNatively() { |
| 281 | + UnsupportedFlinkNodeRecorder.resetForTest(); |
| 282 | + long before = System.currentTimeMillis() / 1000; |
| 283 | + List<Row> rows = CollectionUtil.iteratorToList( |
| 284 | + tableEnvironment.executeSql("select UNIX_TIMESTAMP() from T1").collect()); |
| 285 | + long after = System.currentTimeMillis() / 1000; |
| 286 | + |
| 287 | + assertThat(UnsupportedFlinkNodeRecorder.peekEmitCount()) |
| 288 | + .as("a non-zero fallback count means the Calc did not run natively") |
| 289 | + .isZero(); |
| 290 | + assertThat(rows) |
| 291 | + .as("one clock-bracketed row per input row; an empty result set means the native" |
| 292 | + + " library implements no arm for this function") |
| 293 | + .hasSize(3) |
| 294 | + .allSatisfy(row -> assertThat((long) row.getField(0)).isBetween(before, after)); |
| 295 | + } |
| 296 | + |
262 | 297 | /** A NOT LIKE filter keeps rows whose string does not match the pattern. */ |
263 | 298 | @Test |
264 | 299 | public void testFilterNotLike() { |
|
0 commit comments