Github user pnowojski commented on a diff in the pull request:
https://github.com/apache/flink/pull/6323#discussion_r202282221
--- Diff:
flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java
---
@@ -214,15 +216,18 @@ private static TableDescriptor
createTableDescriptor(String name, Map<String, Ob
if (typeObject == null || !(typeObject instanceof String)) {
throw new SqlClientException("Invalid 'type' attribute
for table '" + name + "'.");
}
- final String type = (String) config.get(TABLE_TYPE);
+ final String type = (String) typeObject;
+ final Map<String, Object> properties = new HashMap<>(config);
config.remove(TABLE_TYPE);
- final Map<String, String> normalizedConfig =
ConfigUtil.normalizeYaml(config);
- if
(type.equals(TableDescriptorValidator.TABLE_TYPE_VALUE_SOURCE())) {
- return new Source(name, normalizedConfig);
- } else if
(type.equals(TableDescriptorValidator.TABLE_TYPE_VALUE_SINK())) {
- return new Sink(name, normalizedConfig);
- } else if
(type.equals(TableDescriptorValidator.TABLE_TYPE_VALUE_SOURCE_SINK())) {
- return new SourceSink(name, normalizedConfig);
+
+ final Map<String, String> normalizedProperties =
ConfigUtil.normalizeYaml(properties);
+ switch (type) {
+ case TABLE_TYPE_VALUE_SOURCE:
+ return new Source(name, normalizedProperties);
+ case TABLE_TYPE_VALUE_SINK:
+ return new Sink(name, normalizedProperties);
+ case TABLE_TYPE_VALUE_BOTH:
+ return new SourceSink(name,
normalizedProperties);
--- End diff --
```
default:
throw new UnsupportedOperationException(
String.format("Unsupported [%s] value [%s]", TABLE_TYPE, type)
```
---