twalthr commented on code in PR #28928:
URL: https://github.com/apache/flink/pull/28928#discussion_r3729998059
##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/extraction/TypeInferenceExtractorTest.java:
##########
@@ -889,7 +890,56 @@ private static Stream<TestSpec> functionSpecs() {
"Logical type 'BITMAP' does not support a
conversion from or to class
'org.apache.flink.table.types.extraction.TypeInferenceExtractorTest$CustomBitmap'."),
TestSpec.forScalarFunction("Custom Bitmap",
InvalidCustomBitmapTypeFunction2.class)
.expectErrorMessage(
- "Could not extract a valid type inference for
function class
'org.apache.flink.table.types.extraction.TypeInferenceExtractorTest$InvalidCustomBitmapTypeFunction2'."));
+ "Could not extract a valid type inference for
function class
'org.apache.flink.table.types.extraction.TypeInferenceExtractorTest$InvalidCustomBitmapTypeFunction2'."),
+ // ---
+ TestSpec.forScalarFunction("Variant in scalar function",
VariantTypeFunction.class)
+ .expectStaticArgument(
+ StaticArgument.scalar("v",
DataTypes.VARIANT(), false))
+ .expectStaticArgument(
+ StaticArgument.scalar(
+ "array",
DataTypes.ARRAY(DataTypes.VARIANT()), false))
+ .expectStaticArgument(
+ StaticArgument.scalar(
+ "map",
+ DataTypes.MAP(DataTypes.INT(),
DataTypes.VARIANT()),
+ false))
+ .expectStaticArgument(
+ StaticArgument.scalar(
+ "row",
+ DataTypes.ROW(DataTypes.FIELD("a",
DataTypes.VARIANT())),
+ false))
+
.expectOutput(TypeStrategies.explicit(DataTypes.VARIANT())),
+ // ---
+ TestSpec.forAsyncScalarFunction(
Review Comment:
only test scalar function should be enough.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ProcessTableFunctionTestPrograms.java:
##########
@@ -928,6 +930,40 @@ public class ProcessTableFunctionTestPrograms {
"INSERT INTO sink SELECT * FROM f(columnList1 =>
NULL, columnList3 => DESCRIPTOR(a, b, c))")
.build();
+ public static final TableTestProgram PROCESS_VARIANT =
+ TableTestProgram.of(
+ "process-variant",
+ "takes nullable, optional, and not nullable
VARIANT arguments")
+ .setupTemporarySystemFunction("f", VariantFunction.class)
+ .setupSql(BASIC_VALUES)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink")
+ .addSchema(BASE_SINK_SCHEMA)
+ .consumedValues("+I[{null, null,
{\"a\":[1,\"b\"]}}]")
+ .build())
+ .runSql(
+ "INSERT INTO sink SELECT * FROM f("
+ + "variant1 => NULL, "
Review Comment:
add a table arg with a variant column as well
##########
flink-table/flink-table-type-utils/src/main/java/org/apache/flink/table/data/conversion/DataStructureConverters.java:
##########
@@ -198,6 +199,7 @@ public final class DataStructureConverters {
putConverter(LogicalTypeRoot.RAW, byte[].class,
RawByteArrayConverter::create);
putConverter(LogicalTypeRoot.RAW, RawValueData.class, identity());
putConverter(LogicalTypeRoot.VARIANT, Variant.class, identity());
+ putConverter(LogicalTypeRoot.VARIANT, BinaryVariant.class, identity());
Review Comment:
nit: I'm wondering whether we actually need this I'm not sure if binary
variant should be an internal class of the logical type. Take a look at string:
string has a string data and binary string, but binary string is internal and
not exposed
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/FunctionITCase.java:
##########
@@ -760,6 +763,80 @@ void testRowScalarFunction() throws Exception {
assertThat(TestCollectionTableFactory.getResult()).isEqualTo(sourceData);
}
+ @Test
+ void testVariantScalarFunction() throws Exception {
Review Comment:
Semantic tests replace ITCases. So let's not over-test this. +1 for removal
in this class.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/FunctionITCase.java:
##########
@@ -760,6 +763,80 @@ void testRowScalarFunction() throws Exception {
assertThat(TestCollectionTableFactory.getResult()).isEqualTo(sourceData);
}
+ @Test
+ void testVariantScalarFunction() throws Exception {
Review Comment:
use a semantic test for this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]