You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2018/06/13 12:44:11 UTC

flink git commit: [FLINK-9570] [sql-client] Fix merging of environments

Repository: flink
Updated Branches:
  refs/heads/master 6f59d6759 -> a00a39829


[FLINK-9570] [sql-client] Fix merging of environments

This closes #6157.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/a00a3982
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/a00a3982
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/a00a3982

Branch: refs/heads/master
Commit: a00a39829d9e6cd6ee81c14a7a4eb19ce4e18154
Parents: 6f59d67
Author: Wosin <bl...@gmail.com>
Authored: Tue Jun 12 10:22:59 2018 +0200
Committer: Timo Walther <tw...@apache.org>
Committed: Wed Jun 13 14:43:06 2018 +0200

----------------------------------------------------------------------
 .../flink/table/client/config/Environment.java  |  2 +-
 .../client/gateway/local/EnvironmentTest.java   | 59 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/a00a3982/flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java b/flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java
index 79efda8..0efb665 100644
--- a/flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java
+++ b/flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/config/Environment.java
@@ -133,7 +133,7 @@ public class Environment {
 
 		// merge tables
 		final Map<String, TableDescriptor> tables = new HashMap<>(env1.getTables());
-		mergedEnv.getTables().putAll(env2.getTables());
+		tables.putAll(env2.getTables());
 		mergedEnv.tables = tables;
 
 		// merge execution properties

http://git-wip-us.apache.org/repos/asf/flink/blob/a00a3982/flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/EnvironmentTest.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/EnvironmentTest.java b/flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/EnvironmentTest.java
new file mode 100644
index 0000000..384ad4f
--- /dev/null
+++ b/flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/EnvironmentTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.client.gateway.local;
+
+import org.apache.flink.table.client.config.Environment;
+import org.apache.flink.table.client.gateway.utils.EnvironmentFileUtil;
+
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link Environment}.
+ */
+public class EnvironmentTest {
+
+	private static final String DEFAULTS_ENVIRONMENT_FILE = "test-sql-client-defaults.yaml";
+	private static final String FACTORY_ENVIRONMENT_FILE = "test-sql-client-factory.yaml";
+
+	@Test
+	public void testMerging() throws Exception {
+		final Environment env1 = EnvironmentFileUtil.parseUnmodified(DEFAULTS_ENVIRONMENT_FILE);
+		final Environment env2 = EnvironmentFileUtil.parseModified(
+			FACTORY_ENVIRONMENT_FILE,
+			Collections.singletonMap("TableNumber1", "NewTable"));
+
+		final Environment merged = Environment.merge(env1, env2);
+
+		final Set<String> tables = new HashSet<>();
+		tables.add("TableNumber1");
+		tables.add("TableNumber2");
+		tables.add("NewTable");
+
+		assertEquals(merged.getTables().keySet(), tables);
+		assertTrue(merged.getExecution().isStreamingExecution());
+		assertEquals(merged.getExecution().getMaxParallelism(), 16);
+	}
+}