diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/RuntimeConverter.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/RuntimeConverter.java
index 2b714eaeffa4563fa8301800d8b2d06c923bcf7e..0f483dd3c1a68ecf2ed824de4fc2df0b81851c14 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/RuntimeConverter.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/RuntimeConverter.java
@@ -43,17 +43,25 @@ public interface RuntimeConverter extends Serializable {
/**
* Context for conversions during runtime.
- *
- *
Meant for future extensibility. Use {@link Context#empty()} for now.
*/
interface Context {
/**
- * Empty context.
+ * Runtime classloader for loading user-defined classes.
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Creates a new instance of {@link Context}.
+ *
+ * @param classLoader runtime classloader for loading user-defined classes.
*/
- static Context empty() {
+ static Context create(ClassLoader classLoader) {
return new Context() {
- // nothing to do
+ @Override
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
};
}
}
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeTransformations.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeTransformations.java
index 99e4ff9a817088def5ca2dc0a7dd8005f4d7580c..66da3bcb62ba01bc0efb5d21215a378dcf79217b 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeTransformations.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeTransformations.java
@@ -31,13 +31,21 @@ import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
+import static org.apache.flink.table.types.logical.utils.LogicalTypeUtils.toInternalConversionClass;
+
/**
* Transformations for transforming one data type to another.
*
* @see TypeTransformation
*/
@Internal
-public class TypeTransformations {
+public final class TypeTransformations {
+
+ /**
+ * Transformation that uses internal data structures for all conversion classes.
+ */
+ public static final TypeTransformation TO_INTERNAL_CLASS =
+ (dataType) -> dataType.bridgedTo(toInternalConversionClass(dataType.getLogicalType()));
/**
* Returns a type transformation that transforms data type to a new data type whose conversion
@@ -73,4 +81,10 @@ public class TypeTransformations {
public static TypeTransformation toNullable() {
return DataType::nullable;
}
+
+ // --------------------------------------------------------------------------------------------
+
+ private TypeTransformations() {
+ // no instantiation
+ }
}
diff --git a/flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java b/flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
index 5c45fb050374010c6ce78e1909f731d039361561..e889814a45b8e0e718f9851a89fbf5080d7ecd78 100644
--- a/flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
+++ b/flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
@@ -28,6 +28,7 @@ import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.FromElementsFunction;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.RuntimeConverter;
import org.apache.flink.table.connector.sink.DynamicTableSink;
import org.apache.flink.table.connector.sink.OutputFormatProvider;
import org.apache.flink.table.connector.sink.SinkFunctionProvider;
@@ -376,6 +377,7 @@ public final class TestValuesTableFactory implements DynamicTableSourceFactory,
.createTypeInformation(physicalRowDataType)
.createSerializer(new ExecutionConfig());
DataStructureConverter converter = runtimeProviderContext.createDataStructureConverter(physicalRowDataType);
+ converter.open(RuntimeConverter.Context.create(TestValuesTableFactory.class.getClassLoader()));
Collection values = convertToRowData(data, converter);
if (runtimeSource.equals("SourceFunction")) {
diff --git a/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataFormatConverterWrapper.java b/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataStructureConverterWrapper.java
similarity index 59%
rename from flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataFormatConverterWrapper.java
rename to flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataStructureConverterWrapper.java
index 89688325b21ec48fc65c3f1bae40a3690abafa2a..8e1319d872fb3a65ba0c27026fb5284d561c267f 100644
--- a/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataFormatConverterWrapper.java
+++ b/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/connector/sink/DataStructureConverterWrapper.java
@@ -18,33 +18,35 @@
package org.apache.flink.table.runtime.connector.sink;
+import org.apache.flink.annotation.Internal;
import org.apache.flink.table.connector.sink.DynamicTableSink;
-import org.apache.flink.table.data.util.DataFormatConverters.DataFormatConverter;
+import org.apache.flink.table.data.conversion.DataStructureConverter;
import javax.annotation.Nullable;
/**
- * This class wraps a {@link DataFormatConverter} so it can be used in
- * a {@link DynamicTableSink} as a {@link DynamicTableSink.DataStructureConverter}.
+ * Implementation of {@link DynamicTableSink.DataStructureConverter}.
+ *
+ *
It wraps the internal {@link DataStructureConverter}.
*/
-public final class DataFormatConverterWrapper implements DynamicTableSink.DataStructureConverter {
+@Internal
+class DataStructureConverterWrapper implements DynamicTableSink.DataStructureConverter {
private static final long serialVersionUID = 1L;
- private final DataFormatConverter