From a83c7ca4e494922945f2adac9df1e5cf2603482e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 9 Oct 2026 23:20:33 +0200 Subject: [PATCH] Check the interpolation an omitted argument takes on the typed surface GeneratedSqlSurfaceTest.anOmittedInterpolationIsTheOneOfTheType checks that appendInstant and tintSeqSetGaps, called without an interpolation, take the one the temporal type supports: appending 5 to a tfloat from 1 to 2 keeps 3 instants and appending 3 keeps 2, the middle one on the line of its neighbours, while appending 3 to a tint keeps 3; interp answers Linear and Step; and tintSeqSetGaps splits three instants with a gap of three days into 2 sequences. Witness: over the catalog of MEOS-API master f8f63bd the surface registers no appendInstant over two temporal values, and the test fails on "function appendInstant(tfloat, tfloat) does not exist". Measured over MobilityDB a0480a7d38 and the catalog of MEOS-API catalog/interp-from-signature-type, with the generator of JMEOS main: the 36 tests pass. Why: appendInstant and the sequence set constructors answer on Spark as they do in PostgreSQL. --- .../spark/GeneratedSqlSurfaceTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java b/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java index 933eabd0..ba50dac8 100644 --- a/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java +++ b/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java @@ -144,6 +144,29 @@ void textConstructorsAndOutput() { assertEquals(true, scalar("SELECT spanOverlaps(floatspan_in('[1, 3]'), floatspan_in('[2, 4]'))")); } + @Test + void anOmittedInterpolationIsTheOneOfTheType() { + // appendInstant and the sequence set constructors without an interpolation take the + // one the temporal type supports: linear for a tfloat, step for a tint. A linear + // sequence drops an instant on the line of its neighbours, a step one keeps it. + String tfloat = "tfloatFromText('[1@2020-01-01, 2@2020-01-02]')"; + String tint = "tintFromText('[1@2020-01-01, 2@2020-01-02]')"; + assertEquals(3, scalar("SELECT numInstants(appendInstant(" + tfloat + + ", tfloatFromText('5@2020-01-03')))")); + assertEquals(2, scalar("SELECT numInstants(appendInstant(" + tfloat + + ", tfloatFromText('3@2020-01-03')))")); + assertEquals(3, scalar("SELECT numInstants(appendInstant(" + tint + + ", tintFromText('3@2020-01-03')))")); + assertEquals("Linear", scalar("SELECT interp(appendInstant(" + tfloat + + ", tfloatFromText('5@2020-01-03')))")); + assertEquals("Step", scalar("SELECT interp(appendInstant(" + tint + + ", tintFromText('3@2020-01-03')))")); + // a gap of more than a day between instants starts a new sequence + assertEquals(2, scalar("SELECT numSequences(tintSeqSetGaps(array(" + + "tintFromText('1@2020-01-01'), tintFromText('2@2020-01-02'), " + + "tintFromText('3@2020-01-05')), INTERVAL '1' DAY, CAST(100.0 AS DOUBLE)))")); + } + @Test void arraysCrossAsSparkArrays() { assertEquals("{1, 2, 3}", scalar("SELECT intset_out(set(array(3, 1, 2)))"));