Skip to content

Commit c10c9eb

Browse files
committed
[AURON #1863] Cover the zero-argument UNIX_TIMESTAMP end to end
Assert that SELECT UNIX_TIMESTAMP() returns one clock-bracketed row per input row and that the Calc records no fallback. Both assertions are load-bearing and neither subsumes the other. A zero fallback count establishes that the Calc converted, not that it ran: a native library holding no registry arm for the function still converts at plan time and fails only during execution, where nothing records a fallback. The row count is what establishes that the native plan executed, since a vacuous pass over an empty result set would otherwise read as success.
1 parent 6fc0dc5 commit c10c9eb

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

auron-flink-extension/auron-flink-planner/src/test/java/org/apache/auron/flink/table/runtime/AuronFlinkCalcITCase.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Comparator;
2525
import java.util.List;
2626
import org.apache.auron.flink.table.AuronFlinkTableTestBase;
27+
import org.apache.auron.flink.table.planner.UnsupportedFlinkNodeRecorder;
2728
import org.apache.flink.types.Row;
2829
import org.apache.flink.util.CollectionUtil;
2930
import org.junit.jupiter.api.Test;
@@ -259,6 +260,40 @@ public void testUnixTimestampFixedOffsetTimeZoneFallsBack() {
259260
assertThat(rows).isEqualTo(Arrays.asList(Row.of(1602316801L), Row.of(1602316802L), Row.of(1602316803L)));
260261
}
261262

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+
262297
/** A NOT LIKE filter keeps rows whose string does not match the pattern. */
263298
@Test
264299
public void testFilterNotLike() {

0 commit comments

Comments
 (0)