← Back to Pull requests

[ZEPPELIN-6284] Added Flink 1.20 interpreter. #5032

Open
Neuw84 opened this pull request with 2089 lines diff across 13 files
View on GitHub
Neuw84 Neuw84 commented on Aug 20, 2025 10:57 UTC
Author

What is this PR for?


A few sentences describing the overall goals of the pull request's commits.
First time? Check out the contributing guide - https://zeppelin.apache.org/contribution/contributions.html

Add Flink 1.20 support for Apache Flink interpreter. Being the latest 1.X release and LTS one it is important to be able to support it. For example we can use latest Iceberg versions with it.

What type of PR is it?


Feature

Todos

What is the Jira issue?


Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/
Put link here, and add [ZEPPELIN-Jira number] in PR title, eg. [ZEPPELIN-533]

https://issues.apache.org/jira/browse/ZEPPELIN-6284

How should this be tested?


Strongly recommended: add automated unit tests for any new or changed behavior
Outline any manual steps to test the PR here.

Screenshots (if appropriate)

Questions:


Does the license files need to update? No
Is there breaking changes for older versions? No
  • Does this needs documentation? No
  • Diff: 2089 lines (+2023 / -66) across 13 files Reviewer: Reamer Review duration: 675948m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.68) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.68 · 2089 lines diff across 13 files
    0.68
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.93 · 5 substantive comment(s)
    0.93
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Real PR Conversation Timeline
    34 items
    Neuw84 Neuw84 commented on Aug 20, 2025 10:58 UTC
    Author

    Based on previous work from 1.18 from these pull requests.

    https://github.com/apache/zeppelin/pull/4864
    https://github.com/apache/zeppelin/pull/4739

    jongyoul jongyoul commented on Aug 21, 2025 02:59 UTC
    Contributor

    @Neuw84 Thank you for your contribution. By the way, flink test is failing now. Could you please check and fix them?

    Copilot Copilot commented on code on Aug 21, 2025 05:49 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/shims120/CollectStreamTableSink.java:1
    @@ -0,0 +1,97 @@
    +/*
    + * 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.zeppelin.flink.shims117;

    The package declaration is incorrect. It should be 'org.apache.zeppelin.flink.shims120' to match the directory structure and class purpose for Flink 1.20 shims, not 'shims117'.

    package org.apache.zeppelin.flink.shims120;
    

    Copilot Copilot commented on code on Aug 21, 2025 05:49 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,408 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims117.CollectStreamTableSink;

    The import statement references 'shims117.CollectStreamTableSink' but should reference the local Flink 1.20 implementation. This should be updated to match the correct package name once the CollectStreamTableSink package is fixed.

    import org.apache.zeppelin.flink.shims120.CollectStreamTableSink;
    

    Copilot Copilot commented on code on Aug 21, 2025 05:49 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,408 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims117.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn application mode, FLINK_HOME is container working directory
    +      String flinkHome = new File(".").getAbsolutePath();
    +      return getPyFlinkPythonPath(new File(flinkHome + "/lib/python"));
    +    }
    +
    +    String flinkHome = System.getenv("FLINK_HOME");
    +    if (StringUtils.isNotBlank(flinkHome)) {
    +      return getPyFlinkPythonPath(new File(flinkHome + "/opt/python"));
    +    } else {
    +      throw new IOException("No FLINK_HOME is specified");
    +    }
    +  }
    +
    +  private String getPyFlinkPythonPath(File pyFlinkFolder) throws IOException {
    +    LOGGER.info("Getting pyflink lib from {}", pyFlinkFolder);
    +    if (!pyFlinkFolder.exists() || !pyFlinkFolder.isDirectory()) {
    +      throw new IOException(String.format("PyFlink folder %s does not exist or is not a folder",
    +              pyFlinkFolder.getAbsolutePath()));
    +    }
    +    File[] depFiles = pyFlinkFolder.listFiles();
    +    StringBuilder builder = new StringBuilder();
    +    for (File file : depFiles) {
    +      LOGGER.info("Adding extracted file {} to PYTHONPATH", file.getAbsolutePath());
    +      builder.append(file.getAbsolutePath() + ":");
    +    }
    +    return builder.toString();
    +  }
    +
    +  @Override
    +  public Object getCollectStreamTableSink(InetAddress targetAddress, int targetPort, Object serializer) {
    +    return new CollectStreamTableSink(targetAddress, targetPort, (TypeSerializer<Tuple2<Boolean, Row>>) serializer);
    +  }
    +
    +  @Override
    +  public List collectToList(Object table) throws Exception {
    +    return Lists.newArrayList(((Table) table).execute().collect());
    +  }
    +
    +  @Override
    +  public boolean rowEquals(Object row1, Object row2) {
    +    Row r1 = (Row) row1;
    +    Row r2 = (Row) row2;
    +    r1.setKind(RowKind.INSERT);
    +    r2.setKind(RowKind.INSERT);
    +    return r1.equals(r2);
    +  }
    +
    +  @Override
    +  public Object fromDataSet(Object btenv, Object ds) {
    +    throw new RuntimeException("Conversion from DataSet is not supported in Flink 1.17");
    +  }
    +
    +  @Override
    +  public Object toDataSet(Object btenv, Object table) {
    +    throw new RuntimeException("Conversion to DataSet is not supported in Flink 1.17");

    The error message incorrectly references 'Flink 1.17' but should reference 'Flink 1.20' since this is the Flink120Shims class.

        throw new RuntimeException("Conversion from DataSet is not supported in Flink 1.20");
      }
    
      @Override
      public Object toDataSet(Object btenv, Object table) {
        throw new RuntimeException("Conversion to DataSet is not supported in Flink 1.20");
    

    Copilot Copilot commented on code on Aug 21, 2025 05:49 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,408 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims117.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn application mode, FLINK_HOME is container working directory
    +      String flinkHome = new File(".").getAbsolutePath();
    +      return getPyFlinkPythonPath(new File(flinkHome + "/lib/python"));
    +    }
    +
    +    String flinkHome = System.getenv("FLINK_HOME");
    +    if (StringUtils.isNotBlank(flinkHome)) {
    +      return getPyFlinkPythonPath(new File(flinkHome + "/opt/python"));
    +    } else {
    +      throw new IOException("No FLINK_HOME is specified");
    +    }
    +  }
    +
    +  private String getPyFlinkPythonPath(File pyFlinkFolder) throws IOException {
    +    LOGGER.info("Getting pyflink lib from {}", pyFlinkFolder);
    +    if (!pyFlinkFolder.exists() || !pyFlinkFolder.isDirectory()) {
    +      throw new IOException(String.format("PyFlink folder %s does not exist or is not a folder",
    +              pyFlinkFolder.getAbsolutePath()));
    +    }
    +    File[] depFiles = pyFlinkFolder.listFiles();
    +    StringBuilder builder = new StringBuilder();
    +    for (File file : depFiles) {
    +      LOGGER.info("Adding extracted file {} to PYTHONPATH", file.getAbsolutePath());
    +      builder.append(file.getAbsolutePath() + ":");
    +    }
    +    return builder.toString();
    +  }
    +
    +  @Override
    +  public Object getCollectStreamTableSink(InetAddress targetAddress, int targetPort, Object serializer) {
    +    return new CollectStreamTableSink(targetAddress, targetPort, (TypeSerializer<Tuple2<Boolean, Row>>) serializer);
    +  }
    +
    +  @Override
    +  public List collectToList(Object table) throws Exception {
    +    return Lists.newArrayList(((Table) table).execute().collect());
    +  }
    +
    +  @Override
    +  public boolean rowEquals(Object row1, Object row2) {
    +    Row r1 = (Row) row1;
    +    Row r2 = (Row) row2;
    +    r1.setKind(RowKind.INSERT);
    +    r2.setKind(RowKind.INSERT);
    +    return r1.equals(r2);
    +  }
    +
    +  @Override
    +  public Object fromDataSet(Object btenv, Object ds) {
    +    throw new RuntimeException("Conversion from DataSet is not supported in Flink 1.17");
    +  }
    +
    +  @Override
    +  public Object toDataSet(Object btenv, Object table) {
    +    throw new RuntimeException("Conversion to DataSet is not supported in Flink 1.17");

    The error message incorrectly references 'Flink 1.17' but should reference 'Flink 1.20' since this is the Flink120Shims class.

        throw new RuntimeException("Conversion from DataSet is not supported in Flink 1.20");
      }
    
      @Override
      public Object toDataSet(Object btenv, Object table) {
        throw new RuntimeException("Conversion to DataSet is not supported in Flink 1.20");
    

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Aug 21, 2025 05:49 UTC
    Reviewer

    Pull Request Overview

    This PR adds support for Apache Flink 1.20 interpreter to Apache Zeppelin, enabling users to work with the latest LTS release of Flink. This support includes compatibility with newer Iceberg versions and provides feature parity with existing Flink interpreters.

  • Added Flink 1.20 shims module with complete interpreter implementation

  • Updated build configuration and CI workflows to include Flink 1.20 support

  • Implemented version-specific shims for API compatibility
  • Reviewed Changes

    Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

    <details>
    <summary>Show a summary per file</summary>

    | File | Description |
    | ---- | ----------- |
    | flink/pom.xml | Added flink1.20-shims module and version property |
    | flink/flink1.20-shims/ | Complete shims implementation for Flink 1.20 compatibility |
    | flink/flink-shims/src/main/java/org/apache/zeppelin/flink/FlinkShims.java | Added version detection for Flink 1.20 |
    | flink/flink-scala-2.12/pom.xml | Updated default version and added flink-120 profile |
    | flink/README.md | Updated documentation to include flink1.20-shims |
    | .github/workflows/core.yml | Updated CI to test with Flink 1.20 |
    </details>

    ---

    <sub>Tip: Customize your code reviews with copilot-instructions.md. <a href="/apache/zeppelin/new/master/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>

    Neuw84 Neuw84 commented on Aug 21, 2025 10:46 UTC
    Author

    @jongyoul I have fixed Copilot comments and added the corresponding test file.

    If all is good let me know if I need to clean the "commit log".

    Copilot Copilot commented on code on Aug 21, 2025 10:59 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/TimestampStringUtils.java:1
    @@ -0,0 +1,143 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.sql.Time;
    +import java.time.LocalDateTime;
    +import java.time.LocalTime;
    +import java.util.TimeZone;
    +
    +/**
    + * Copied from flink-project with minor modification.
    + * */
    +public class TimestampStringUtils {
    +
    +  private static final TimeZone LOCAL_TZ = TimeZone.getDefault();
    +
    +  public TimestampStringUtils() {
    +  }
    +
    +  public static String timestampToString(LocalDateTime ldt, int precision) {
    +    String fraction;
    +    for(fraction = pad(9, (long)ldt.getNano()); fraction.length() > precision && fraction.endsWith("0"); fraction = fraction.substring(0, fraction.length() - 1)) {
    +    }
    +
    +    StringBuilder ymdhms = ymdhms(new StringBuilder(), ldt.getYear(), ldt.getMonthValue(), ldt.getDayOfMonth(), ldt.getHour(), ldt.getMinute(), ldt.getSecond());
    +    if (fraction.length() > 0) {
    +      ymdhms.append(".").append(fraction);
    +    }
    +
    +    return ymdhms.toString();
    +  }
    +
    +  private static String pad(int length, long v) {
    +    StringBuilder s = new StringBuilder(Long.toString(v));
    +
    +    while(s.length() < length) {
    +      s.insert(0, "0");
    +    }
    +
    +    return s.toString();
    +  }
    +
    +  private static StringBuilder hms(StringBuilder b, int h, int m, int s) {
    +    int2(b, h);
    +    b.append(':');
    +    int2(b, m);
    +    b.append(':');
    +    int2(b, s);
    +    return b;
    +  }
    +
    +  private static StringBuilder ymdhms(StringBuilder b, int year, int month, int day, int h, int m, int s) {
    +    ymd(b, year, month, day);
    +    b.append(' ');
    +    hms(b, h, m, s);
    +    return b;
    +  }
    +
    +  private static StringBuilder ymd(StringBuilder b, int year, int month, int day) {
    +    int4(b, year);
    +    b.append('-');
    +    int2(b, month);
    +    b.append('-');
    +    int2(b, day);
    +    return b;
    +  }
    +
    +  private static void int4(StringBuilder buf, int i) {
    +    buf.append((char)(48 + i / 1000 % 10));
    +    buf.append((char)(48 + i / 100 % 10));
    +    buf.append((char)(48 + i / 10 % 10));
    +    buf.append((char)(48 + i % 10));
    +  }
    +
    +  private static void int2(StringBuilder buf, int i) {
    +    buf.append((char)(48 + i / 10 % 10));
    +    buf.append((char)(48 + i % 10));
    +  }
    +
    +  public static String unixTimeToString(int time) {
    +    StringBuilder buf = new StringBuilder(8);
    +    unixTimeToString(buf, time, 0);
    +    return buf.toString();
    +  }
    +
    +  private static void unixTimeToString(StringBuilder buf, int time, int precision) {
    +    while(time < 0) {
    +      time = (int)((long)time + 86400000L);
    +    }
    +
    +    int h = time / 3600000;
    +    int time2 = time % 3600000;
    +    int m = time2 / '\uea60';
    +    int time3 = time2 % '\uea60';
    +    int s = time3 / 1000;
    +    int ms = time3 % 1000;
    +    int2(buf, h);
    +    buf.append(':');
    +    int2(buf, m);
    +    buf.append(':');
    +    int2(buf, s);
    +    if (precision > 0) {
    +      buf.append('.');
    +
    +      while(precision > 0) {
    +        buf.append((char)(48 + ms / 100));
    +        ms %= 100;
    +        ms *= 10;
    +        if (ms == 0) {
    +          break;
    +        }
    +
    +        --precision;
    +      }
    +    }
    +
    +  }
    +
    +  public static int timeToInternal(Time time) {
    +    long ts = time.getTime() + (long)LOCAL_TZ.getOffset(time.getTime());
    +    return (int)(ts % 86400000L);
    +  }
    +
    +  public static int localTimeToUnixDate(LocalTime time) {
    +    return time.getHour() * 3600000 + time.getMinute() * '\uea60' + time.getSecond() * 1000 + time.getNano() / 1000000;

    Using a Unicode character literal '\uea60' (60000) for milliseconds conversion is unclear and error-prone. Replace with the explicit constant 60000 or a named constant like MILLISECONDS_PER_MINUTE.

        return time.getHour() * 3600000 + time.getMinute() * MILLISECONDS_PER_MINUTE + time.getSecond() * 1000 + time.getNano() / 1000000;
    

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Aug 21, 2025 10:59 UTC
    Reviewer

    Pull Request Overview

    This PR adds support for Apache Flink 1.20 interpreter to Zeppelin, bringing compatibility with the latest LTS release of Flink 1.x series.

    Key changes include:

  • Creation of Flink 1.20 shims implementation with necessary adapters and utilities

  • Addition of Python environment configuration for Flink 1.20 testing

  • Updates to build configuration and CI workflows to include Flink 1.20 support
  • Reviewed Changes

    Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

    <details>
    <summary>Show a summary per file</summary>

    | File | Description |
    | ---- | ----------- |
    | testing/env_python_3_with_flink_120.yml | New conda environment configuration for Python 3 with Flink 1.20.0 |
    | flink/pom.xml | Adds flink1.20-shims module and version property |
    | flink/flink1.20-shims/ | New module containing Flink 1.20 specific implementations and adapters |
    | flink/flink-shims/src/main/java/org/apache/zeppelin/flink/FlinkShims.java | Updates shim loader to recognize Flink 1.20 |
    | flink/flink-scala-2.12/pom.xml | Updates default Flink version and adds Flink 1.20 profile |
    | flink/README.md | Updates documentation to include flink1.20-shims module |
    | .github/workflows/core.yml | Updates CI to test with Flink 1.20 |
    </details>

    <details>
    <summary>Comments suppressed due to low confidence (2)</summary>

    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/PrintUtils.java:109
    Using a Unicode character literal '\uea60' (60000) for milliseconds conversion is unclear and error-prone. Replace with the explicit constant 60000 or a named constant like MILLISECONDS_PER_MINUTE.

                formattedArray[i] =
    

    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/PrintUtils.java:110
    Using a Unicode character literal '\uea60' (60000) for milliseconds conversion is unclear and error-prone. Replace with the explicit constant 60000 or a named constant like MILLISECONDS_PER_MINUTE.
                        formattedTimestamp(array.get(i), elementType, sessionTimeZone);
    

    </details>

    ---

    <sub>Tip: Customize your code reviews with copilot-instructions.md. <a href="/apache/zeppelin/new/master/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>

    Neuw84 Neuw84 commented on Aug 21, 2025 13:02 UTC
    Author

    Unmmm, looking at the docs I see this weird error. Seems like it is not being able to launch the cluster, but a little bit lost here.

     WARN [2025-08-21 11:04:10,021] ({flink-metrics-pekko.actor.supervisor-dispatcher-5} SupervisorActor.java[rpcActorFailed]:144) - RpcActor pekko://flink-metrics/user/rpc/MetricQueryService has failed. Shutting it down now.
    java.lang.NullPointerException
    	at org.slf4j.impl.Reload4jMDCAdapter.setContextMap(Reload4jMDCAdapter.java:81)
    	at org.slf4j.MDC.setContextMap(MDC.java:264)
    	at org.apache.flink.util.MdcUtils.lambda$withContext$0(MdcUtils.java:48)
    	at org.apache.flink.runtime.rpc.pekko.PekkoRpcActor.handleControlMessage(PekkoRpcActor.java:208)
    	at org.apache.pekko.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:33)
    	at org.apache.pekko.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:29)
    	at scala.PartialFunction.applyOrElse(PartialFunction.scala:127)
    	at scala.PartialFunction.applyOrElse$(PartialFunction.scala:126)
    	at org.apache.pekko.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:29)
    	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:175)
    	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:176)
    	at org.apache.pekko.actor.Actor.aroundReceive(Actor.scala:547)
    	at org.apache.pekko.actor.Actor.aroundReceive$(Actor.scala:545)
    	at org.apache.pekko.actor.AbstractActor.aroundReceive(AbstractActor.scala:229)
    	at org.apache.pekko.actor.ActorCell.receiveMessage(ActorCell.scala:590)
    	at org.apache.pekko.actor.ActorCell.invoke(ActorCell.scala:557)
    	at org.apache.pekko.dispatch.Mailbox.processMailbox(Mailbox.scala:280)
    	at org.apache.pekko.dispatch.Mailbox.run(Mailbox.scala:241)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
     WARN [2025-08-21 11:04:10,031] ({main} HadoopUtils.java[getHadoopConfiguration]:139) - Could not find Hadoop configuration via any of the supported methods (Flink configuration, environment variables).
    
    

    Any help is appreciated as the Exception do not provide much info....

    Indeed the code that is present here is working at least for Scala and SQL interfaces ( checked with some Notebooks) with Java 11.

    Neuw84 Neuw84 commented on Aug 21, 2025 13:54 UTC
    Author

    Seems that the error comes from a NPE Exception from Log4j.

    Flink 1.20.2 seems to address the issue.

    https://flink.apache.org/2025/07/10/apache-flink-1.20.2-release-announcement/?utm_source=chatgpt.com

    Neuw84 Neuw84 commented on Aug 21, 2025 14:58 UTC
    Author

    Log4j issue solved with upgrade to 1.20.2, now I am getting a fancy scala error with some version mismatch.

    error reading Scala signature of org.apache.flink.table.api.ImplicitExpressionConversions: unsafe symbol x$2 (child of value <local api>) in runtime reflection universe

    to reproduce them.

    mvn -pl flink/flink-scala-2.12 -Pflink-120  clean install -DskipTests -am
    mvn -pl flink/flink-scala-2.12 -Pflink-120 test
    

    Tried to fix it but without luck yet.

    Using a docker-compose setup to connect Zeppelin to a Flink cluster on 1.20.2 with this code work as expected ( Scala , SQL interfaces).

    jongyoul jongyoul commented on Aug 21, 2025 15:06 UTC
    Contributor

    @zjffdu Could you please help to fix the error if you could share your time to review it?

    Neuw84 Neuw84 commented on Aug 21, 2025 18:46 UTC
    Author

    After some research I wasn´t able to identify the offending library. Spend some time time trying to fix scala versions without luck via maven.

    The code works well as said on my previous comment, should be a thing of scala-reflect/compiler used on the tests but no clue.

    Reamer Reamer commented on code on Aug 22, 2025 08:56 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/shims120/CollectStreamTableSink.java:1
    @@ -0,0 +1,97 @@
    +/*
    + * 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.zeppelin.flink.shims120;
    +
    +import org.apache.flink.api.common.typeinfo.TypeInformation;
    +import org.apache.flink.api.common.typeinfo.Types;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.api.java.typeutils.TupleTypeInfo;
    +import org.apache.flink.streaming.api.datastream.DataStream;
    +import org.apache.flink.streaming.api.datastream.DataStreamSink;
    +import org.apache.flink.streaming.experimental.CollectSink;
    +import org.apache.flink.table.sinks.RetractStreamTableSink;
    +import org.apache.flink.types.Row;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.net.InetAddress;
    +import java.util.UUID;
    +
    +/**
    + * Table sink for collecting the results locally using sockets.
    + */
    +public class CollectStreamTableSink implements RetractStreamTableSink<Row> {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(CollectStreamTableSink.class);
    +
    +  private final InetAddress targetAddress;
    +  private final int targetPort;
    +  private final TypeSerializer<Tuple2<Boolean, Row>> serializer;
    +
    +  private String[] fieldNames;
    +  private TypeInformation<?>[] fieldTypes;
    +
    +  public CollectStreamTableSink(InetAddress targetAddress,
    +                                int targetPort,
    +                                TypeSerializer<Tuple2<Boolean, Row>> serializer) {
    +    LOGGER.info("Use address: " + targetAddress.getHostAddress() + ":" + targetPort);

        LOGGER.info("Use address: {}:{}", targetAddress.getHostAddress(), targetPort);
    

    Reamer Reamer commented on code on Aug 22, 2025 08:59 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,408 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims120.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn application mode, FLINK_HOME is container working directory
    +      String flinkHome = new File(".").getAbsolutePath();

    We should use the new Files and Paths API to interact with folders and files.

    Reamer Reamer requested changes on Aug 22, 2025 09:00 UTC
    Changes Requested Reviewer

    We are now using a newer JDK version and should also be using the new Java tools.

    Neuw84 Neuw84 commented on code on Aug 22, 2025 09:38 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/shims120/CollectStreamTableSink.java:1
    @@ -0,0 +1,97 @@
    +/*
    + * 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.zeppelin.flink.shims120;
    +
    +import org.apache.flink.api.common.typeinfo.TypeInformation;
    +import org.apache.flink.api.common.typeinfo.Types;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.api.java.typeutils.TupleTypeInfo;
    +import org.apache.flink.streaming.api.datastream.DataStream;
    +import org.apache.flink.streaming.api.datastream.DataStreamSink;
    +import org.apache.flink.streaming.experimental.CollectSink;
    +import org.apache.flink.table.sinks.RetractStreamTableSink;
    +import org.apache.flink.types.Row;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.net.InetAddress;
    +import java.util.UUID;
    +
    +/**
    + * Table sink for collecting the results locally using sockets.
    + */
    +public class CollectStreamTableSink implements RetractStreamTableSink<Row> {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(CollectStreamTableSink.class);
    +
    +  private final InetAddress targetAddress;
    +  private final int targetPort;
    +  private final TypeSerializer<Tuple2<Boolean, Row>> serializer;
    +
    +  private String[] fieldNames;
    +  private TypeInformation<?>[] fieldTypes;
    +
    +  public CollectStreamTableSink(InetAddress targetAddress,
    +                                int targetPort,
    +                                TypeSerializer<Tuple2<Boolean, Row>> serializer) {
    +    LOGGER.info("Use address: " + targetAddress.getHostAddress() + ":" + targetPort);

    fixed.

    Neuw84 Neuw84 commented on code on Aug 22, 2025 09:38 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,408 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims120.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn application mode, FLINK_HOME is container working directory
    +      String flinkHome = new File(".").getAbsolutePath();

    changed on latest commit.

    Reamer Reamer commented on code on Aug 22, 2025 11:45 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,423 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.nio.file.Files;
    +import java.nio.file.Path;
    +import java.nio.file.Paths;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import java.util.StringJoiner;
    +import java.util.stream.Stream;
    +
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims120.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +
    +    final Path pyDir;
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn-application mode, FLINK_HOME is the container working directory
    +      Path flinkHome = Paths.get(".").toAbsolutePath().normalize();
    +      pyDir = flinkHome.resolve("lib").resolve("python");
    +    } else {
    +      String flinkHome = System.getenv("FLINK_HOME");
    +      if (flinkHome != null && !flinkHome.isBlank()) {
    +        pyDir = Paths.get(flinkHome).resolve("opt").resolve("python");

    Why do you use Paths.resolve() in various places?
    I would have shortened it to Paths.get(flinkHome, “opt”, "python").

    Neuw84 Neuw84 commented on code on Aug 22, 2025 12:51 UTC
    Code Review
    flink/flink1.20-shims/src/main/java/org/apache/zeppelin/flink/Flink120Shims.java:1
    @@ -0,0 +1,423 @@
    +/*
    + * 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.zeppelin.flink;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.net.InetAddress;
    +import java.net.URL;
    +import java.nio.file.Files;
    +import java.nio.file.Path;
    +import java.nio.file.Paths;
    +import java.time.ZoneId;
    +import java.util.List;
    +import java.util.Properties;
    +import java.util.StringJoiner;
    +import java.util.stream.Stream;
    +
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.compress.utils.Lists;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.commons.lang3.tuple.ImmutablePair;
    +import org.apache.flink.api.common.RuntimeExecutionMode;
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.client.cli.CliFrontend;
    +import org.apache.flink.client.cli.CustomCommandLine;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.ExecutionOptions;
    +import org.apache.flink.configuration.ReadableConfig;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory;
    +import org.apache.flink.table.api.*;
    +import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
    +import org.apache.flink.table.api.config.TableConfigOptions;
    +import org.apache.flink.table.catalog.*;
    +import org.apache.flink.table.client.resource.ClientResourceManager;
    +import org.apache.flink.table.client.util.ClientClassloaderUtil;
    +import org.apache.flink.table.client.util.ClientWrapperClassLoader;
    +import org.apache.flink.table.delegation.Executor;
    +import org.apache.flink.table.delegation.ExecutorFactory;
    +import org.apache.flink.table.delegation.Planner;
    +import org.apache.flink.table.factories.CatalogStoreFactory;
    +import org.apache.flink.table.factories.FactoryUtil;
    +import org.apache.flink.table.factories.PlannerFactoryUtil;
    +import org.apache.flink.table.factories.TableFactoryUtil;
    +import org.apache.flink.table.functions.AggregateFunction;
    +import org.apache.flink.table.functions.ScalarFunction;
    +import org.apache.flink.table.functions.TableAggregateFunction;
    +import org.apache.flink.table.functions.TableFunction;
    +import org.apache.flink.table.module.ModuleManager;
    +import org.apache.flink.table.resource.ResourceManager;
    +import org.apache.flink.table.sinks.TableSink;
    +import org.apache.flink.table.typeutils.TimeIndicatorTypeInfo;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.types.RowKind;
    +import org.apache.flink.util.FlinkException;
    +import org.apache.zeppelin.flink.shims120.CollectStreamTableSink;
    +import org.apache.zeppelin.interpreter.InterpreterContext;
    +import org.apache.zeppelin.interpreter.InterpreterResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Shims for flink 1.20
    + */
    +public class Flink120Shims extends FlinkShims {
    +
    +  private static final Logger LOGGER = LoggerFactory.getLogger(Flink120Shims.class);
    +
    +  private Flink120SqlInterpreter batchSqlInterpreter;
    +  private Flink120SqlInterpreter streamSqlInterpreter;
    +
    +  public Flink120Shims(FlinkVersion flinkVersion, Properties properties) {
    +    super(flinkVersion, properties);
    +  }
    +
    +  public void initInnerBatchSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.batchSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, true);
    +  }
    +
    +  public void initInnerStreamSqlInterpreter(FlinkSqlContext flinkSqlContext) {
    +    this.streamSqlInterpreter = new Flink120SqlInterpreter(flinkSqlContext, false);
    +  }
    +
    +  @Override
    +  public Object createResourceManager(List<URL> jars, Object tableConfig) {
    +    Configuration configuration = ((TableConfig) tableConfig).getConfiguration().clone();
    +    ClientWrapperClassLoader userClassLoader =
    +            new ClientWrapperClassLoader(
    +                    ClientClassloaderUtil.buildUserClassLoader(
    +                            jars,
    +                            Thread.currentThread().getContextClassLoader(),
    +                            new Configuration(configuration)),
    +                    configuration);
    +    return new ClientResourceManager(configuration, userClassLoader);
    +  }
    +
    +  @Override
    +  public Object createFunctionCatalog(Object tableConfig, Object catalogManager, Object moduleManager, List<URL> jars) {
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +    return new FunctionCatalog((TableConfig) tableConfig, resourceManager, (CatalogManager) catalogManager, (ModuleManager) moduleManager);
    +  }
    +
    +  @Override
    +  public void disableSysoutLogging(Object batchConfig, Object streamConfig) {
    +    // do nothing
    +  }
    +
    +  @Override
    +  public Object createScalaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                       Object senvObj,
    +                                                       Object tableConfigObj,
    +                                                       Object moduleManagerObj,
    +                                                       Object functionCatalogObj,
    +                                                       Object catalogManagerObj,
    +                                                       List<URL> jars,
    +                                                       ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl(catalogManager,
    +            moduleManager, resourceManager,
    +            functionCatalog, tableConfig, new org.apache.flink.streaming.api.scala.StreamExecutionEnvironment(senv),
    +            planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createJavaBlinkStreamTableEnvironment(Object environmentSettingsObj,
    +                                                      Object senvObj,
    +                                                      Object tableConfigObj,
    +                                                      Object moduleManagerObj,
    +                                                      Object functionCatalogObj,
    +                                                      Object catalogManagerObj,
    +                                                      List<URL> jars,
    +                                                      ClassLoader classLoader) {
    +    EnvironmentSettings environmentSettings = (EnvironmentSettings) environmentSettingsObj;
    +    StreamExecutionEnvironment senv = (StreamExecutionEnvironment) senvObj;
    +    TableConfig tableConfig = (TableConfig) tableConfigObj;
    +    ModuleManager moduleManager = (ModuleManager) moduleManagerObj;
    +    FunctionCatalog functionCatalog = (FunctionCatalog) functionCatalogObj;
    +    CatalogManager catalogManager = (CatalogManager) catalogManagerObj;
    +    ImmutablePair<Object, Object> pair = createPlannerAndExecutor(
    +            classLoader, environmentSettings, senv,
    +            tableConfig, moduleManager, functionCatalog, catalogManager);
    +    Planner planner = (Planner) pair.left;
    +    Executor executor = (Executor) pair.right;
    +
    +    ResourceManager resourceManager = (ResourceManager) createResourceManager(jars, tableConfig);
    +
    +    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, resourceManager,
    +            functionCatalog, tableConfig, senv, planner, executor, environmentSettings.isStreamingMode());
    +  }
    +
    +  @Override
    +  public Object createStreamExecutionEnvironmentFactory(Object streamExecutionEnvironment) {
    +    return new StreamExecutionEnvironmentFactory() {
    +      @Override
    +      public StreamExecutionEnvironment createExecutionEnvironment(Configuration configuration) {
    +        return (StreamExecutionEnvironment) streamExecutionEnvironment;
    +      }
    +    };
    +  }
    +
    +  @Override
    +  public Object createCatalogManager(Object config) {
    +    final TableConfig tableConfig = TableConfig.getDefault();
    +    ClassLoader userClassLoader=Thread.currentThread().getContextClassLoader();
    +
    +    final CatalogStoreFactory catalogStoreFactory =
    +            TableFactoryUtil.findAndCreateCatalogStoreFactory(
    +                    tableConfig.getConfiguration(), userClassLoader);
    +    final CatalogStore catalogStore =
    +                    catalogStoreFactory.createCatalogStore();
    +
    +    return CatalogManager.newBuilder()
    +                    .classLoader(Thread.currentThread().getContextClassLoader())
    +                    .config((ReadableConfig) config)
    +                    .defaultCatalog(
    +                            "default_catalog",
    +                            new GenericInMemoryCatalog(
    +                                    "default_catalog",
    +                                    "default_database"))
    +                    . catalogStoreHolder(
    +            CatalogStoreHolder.newBuilder()
    +                    .classloader(Thread.currentThread().getContextClassLoader())
    +                    .config(tableConfig)
    +                    .catalogStore(catalogStore)
    +                    .factory(catalogStoreFactory)
    +                    .build())
    +            .build();
    +  }
    +
    +  @Override
    +  public String getPyFlinkPythonPath(Properties properties) throws IOException {
    +    String mode = properties.getProperty("flink.execution.mode");
    +
    +    final Path pyDir;
    +    if ("yarn-application".equalsIgnoreCase(mode)) {
    +      // for yarn-application mode, FLINK_HOME is the container working directory
    +      Path flinkHome = Paths.get(".").toAbsolutePath().normalize();
    +      pyDir = flinkHome.resolve("lib").resolve("python");
    +    } else {
    +      String flinkHome = System.getenv("FLINK_HOME");
    +      if (flinkHome != null && !flinkHome.isBlank()) {
    +        pyDir = Paths.get(flinkHome).resolve("opt").resolve("python");

    fixed.

    Neuw84 Neuw84 commented on Aug 22, 2025 12:53 UTC
    Author

    After digging and digging with scala libraries I think that the error is not solvable.... I don't see any scala library collisions and tried forcing many versions.

    Seems that they changed how you need to create the environments and that should updated on ScalaInterpreter.

    We should have a codepath for 1.17 and below and one for 1.20 now.

    pan3793 pan3793 commented on Aug 25, 2025 10:33 UTC
    Contributor

    now I am getting a fancy scala error with some version mismatch.

    > error reading Scala signature of org.apache.flink.table.api.ImplicitExpressionConversions: unsafe symbol x$2 (child of value <local api>) in runtime reflection universe

    This is why I abandoned the previous PR ... recompiling Flink with a higher Scala version does not work either ... the key point here is FLINK-32560 added a @deprecated(since = "1.18.0") to trait ImplicitExpressionConversions, the issue will go away if we revert FLINK-32560

    pan3793 pan3793 commented on Aug 25, 2025 10:34 UTC
    Contributor

    FLINK-36327 replaces the @deprecated(since = "1.18.0") with Java's @Deprecated, you may want to try Flink 2.0

    A-Maniovich A-Maniovich commented on Aug 27, 2025 08:55 UTC
    Contributor

    That would be great!

    A-Maniovich A-Maniovich commented on Aug 27, 2025 08:59 UTC
    Contributor

    I dont know if you have noticed or not, but the error isn't actually fatal. If you try to run the cell a second time it surprisingly will work without any problems.

    error reading Scala signature of org.apache.flink.table.api.ImplicitExpressionConversions: unsafe symbol x$2 (child of value <local api>) in runtime reflection universe
    

    pan3793 pan3793 commented on Aug 27, 2025 09:01 UTC
    Contributor

    I dont know if you have noticed or not, but the error isn't actually fatal. If you try to run the cell a second time it surprisingly will work without any problems.

    >
    > error reading Scala signature of org.apache.flink.table.api.ImplicitExpressionConversions: unsafe symbol x$2 (child of value <local api>) in runtime reflection universe
    > 

    I also noticed that, but have no idea why, due to my limited knowledge of scala internal :(

    pan3793 pan3793 commented on Aug 27, 2025 09:03 UTC
    Contributor

    I think there are two directions now:

    1. try Flink 2.0 to see if FLINK-36327 helps
    2. eliminate usage of Flink's Scala API since it was deprecated by Flink for a long time.

    Neuw84 Neuw84 commented on Aug 27, 2025 11:12 UTC
    Author

    The problem is that Flink 2.0 deletes all scala APIs, that would mean that we need to rewrite the Flink interpreter and see what are the ideal options there. SQL interface ok, but then... python+java repl? It would need a huge rearchitecture....

    I will try to spend more time on this (Flink 1.20) but I can't promise anything, any help would be appreciated. As it is know it works but I would like this to be merged to have at least LTS support before migrate to Flink 2.0...

    hyunw9 hyunw9 commented on Nov 11, 2025 23:54 UTC
    Contributor

    @Neuw84 If it’s okay with you, I’d like to help too.

    Neuw84 Neuw84 commented on Nov 12, 2025 05:46 UTC
    Author

    go for it, the code is working well as I having been using heavily it for a re:Invent workshop I am building for next month. It is a matter of solving those scala collisions on testing.

    jongyoul jongyoul commented on May 29, 2026 03:37 UTC
    Contributor

    Hello @Neuw84, I missed this PR and submit and merge my one first. I'm sorry for interrupting it. By the way, I think my PR meets the minimum bar to work with new version of Flink 1.20 but I hope it could be improved more and more. Could you please help give your experience to improve the featue? I will review it with priority. 🙏

    Reviewers
    Assignees
    Neuw84 Neuw84
    Labels
    risk: low confidence: 90.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 67.6% (HIGH) · Higher = larger blast radius
    67.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.4% · Lower = rushed or shallow review
    90.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.5% · Safe to merge
    6.5%