You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by pv...@apache.org on 2022/11/17 13:56:10 UTC

[iceberg] branch master updated: Flink: Extract Flink package version programmatically for EnvironmentContext engine-version (#6206)

This is an automated email from the ASF dual-hosted git repository.

pvary pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new bcc4fa07fd Flink: Extract Flink package version programmatically for EnvironmentContext engine-version (#6206)
bcc4fa07fd is described below

commit bcc4fa07fd443c25b9a0b2cdd6b0e74eabf8ebc0
Author: Steven Zhen Wu <st...@gmail.com>
AuthorDate: Thu Nov 17 05:56:04 2022 -0800

    Flink: Extract Flink package version programmatically for EnvironmentContext engine-version (#6206)
---
 .../org/apache/iceberg/flink/FlinkCatalog.java     |  3 +-
 .../apache/iceberg/flink/util/FlinkPackage.java    | 33 ++++++++++++++++++++++
 .../org/apache/iceberg/flink/FlinkCatalog.java     |  3 +-
 .../apache/iceberg/flink/util/FlinkPackage.java    | 33 ++++++++++++++++++++++
 .../org/apache/iceberg/flink/FlinkCatalog.java     |  3 +-
 .../apache/iceberg/flink/util/FlinkPackage.java    | 33 ++++++++++++++++++++++
 6 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java b/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
index 718233dfec..54f35a00a5 100644
--- a/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
+++ b/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
@@ -70,6 +70,7 @@ import org.apache.iceberg.exceptions.AlreadyExistsException;
 import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
 import org.apache.iceberg.exceptions.NoSuchNamespaceException;
 import org.apache.iceberg.flink.util.FlinkCompatibilityUtil;
+import org.apache.iceberg.flink.util.FlinkPackage;
 import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
@@ -120,7 +121,7 @@ public class FlinkCatalog extends AbstractCatalog {
     closeable = originalCatalog instanceof Closeable ? (Closeable) originalCatalog : null;
 
     EnvironmentContext.put(EnvironmentContext.ENGINE_NAME, "flink");
-    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, "1.14");
+    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, FlinkPackage.version());
   }
 
   @Override
diff --git a/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java b/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
new file mode 100644
index 0000000000..23955f80a3
--- /dev/null
+++ b/flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
@@ -0,0 +1,33 @@
+/*
+ * 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.iceberg.flink.util;
+
+import org.apache.flink.streaming.api.datastream.DataStream;
+
+public class FlinkPackage {
+  /** Choose {@link DataStream} class because it is one of the core Flink API. */
+  private static final String VERSION = DataStream.class.getPackage().getImplementationVersion();
+
+  private FlinkPackage() {}
+
+  /** @return Flink version string like x.y.z */
+  public static String version() {
+    return VERSION;
+  }
+}
diff --git a/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java b/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
index b29951a81c..54f35a00a5 100644
--- a/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
+++ b/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
@@ -70,6 +70,7 @@ import org.apache.iceberg.exceptions.AlreadyExistsException;
 import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
 import org.apache.iceberg.exceptions.NoSuchNamespaceException;
 import org.apache.iceberg.flink.util.FlinkCompatibilityUtil;
+import org.apache.iceberg.flink.util.FlinkPackage;
 import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
@@ -120,7 +121,7 @@ public class FlinkCatalog extends AbstractCatalog {
     closeable = originalCatalog instanceof Closeable ? (Closeable) originalCatalog : null;
 
     EnvironmentContext.put(EnvironmentContext.ENGINE_NAME, "flink");
-    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, "1.15");
+    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, FlinkPackage.version());
   }
 
   @Override
diff --git a/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java b/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
new file mode 100644
index 0000000000..23955f80a3
--- /dev/null
+++ b/flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
@@ -0,0 +1,33 @@
+/*
+ * 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.iceberg.flink.util;
+
+import org.apache.flink.streaming.api.datastream.DataStream;
+
+public class FlinkPackage {
+  /** Choose {@link DataStream} class because it is one of the core Flink API. */
+  private static final String VERSION = DataStream.class.getPackage().getImplementationVersion();
+
+  private FlinkPackage() {}
+
+  /** @return Flink version string like x.y.z */
+  public static String version() {
+    return VERSION;
+  }
+}
diff --git a/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java b/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
index a9c2a2e761..54f35a00a5 100644
--- a/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
+++ b/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java
@@ -70,6 +70,7 @@ import org.apache.iceberg.exceptions.AlreadyExistsException;
 import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
 import org.apache.iceberg.exceptions.NoSuchNamespaceException;
 import org.apache.iceberg.flink.util.FlinkCompatibilityUtil;
+import org.apache.iceberg.flink.util.FlinkPackage;
 import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
@@ -120,7 +121,7 @@ public class FlinkCatalog extends AbstractCatalog {
     closeable = originalCatalog instanceof Closeable ? (Closeable) originalCatalog : null;
 
     EnvironmentContext.put(EnvironmentContext.ENGINE_NAME, "flink");
-    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, "1.16");
+    EnvironmentContext.put(EnvironmentContext.ENGINE_VERSION, FlinkPackage.version());
   }
 
   @Override
diff --git a/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java b/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
new file mode 100644
index 0000000000..23955f80a3
--- /dev/null
+++ b/flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/util/FlinkPackage.java
@@ -0,0 +1,33 @@
+/*
+ * 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.iceberg.flink.util;
+
+import org.apache.flink.streaming.api.datastream.DataStream;
+
+public class FlinkPackage {
+  /** Choose {@link DataStream} class because it is one of the core Flink API. */
+  private static final String VERSION = DataStream.class.getPackage().getImplementationVersion();
+
+  private FlinkPackage() {}
+
+  /** @return Flink version string like x.y.z */
+  public static String version() {
+    return VERSION;
+  }
+}