Skip to content

Commit 086cba7

Browse files
committed
test(udf): exercise all three Volatility kinds
1 parent 4ef01fd commit 086cba7

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

core/src/test/java/org/apache/datafusion/ScalarUdfTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,26 @@ void udfAppliedToMultiRowQuery_processesAllRows() throws Exception {
441441
}
442442
}
443443
}
444+
445+
@Test
446+
void volatilityBytesRoundTrip_forAllThreeKinds() throws Exception {
447+
for (Volatility v : Volatility.values()) {
448+
try (SessionContext ctx = new SessionContext();
449+
BufferAllocator allocator = new RootAllocator()) {
450+
ctx.registerUdf(
451+
"add_one_" + v.name().toLowerCase(),
452+
new AddOne(),
453+
new ArrowType.Int(32, true),
454+
List.of(new ArrowType.Int(32, true)),
455+
v);
456+
try (DataFrame df =
457+
ctx.sql("SELECT add_one_" + v.name().toLowerCase() + "(CAST(0 AS INT))");
458+
ArrowReader r = df.collect(allocator)) {
459+
assertEquals(true, r.loadNextBatch());
460+
IntVector y = (IntVector) r.getVectorSchemaRoot().getVector(0);
461+
assertEquals(1, y.get(0));
462+
}
463+
}
464+
}
465+
}
444466
}

0 commit comments

Comments
 (0)