forked from apache/paimon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[flink] Remove compatibility utils that are used for flink-1.…
…14 (apache#3054)" This reverts commit e589a42
- Loading branch information
1 parent
0c3773d
commit e8628c8
Showing
13 changed files
with
174 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/TableConfigUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.paimon.flink; | ||
|
||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.configuration.ReadableConfig; | ||
import org.apache.flink.table.api.TableConfig; | ||
|
||
/** Utils for {@link TableConfig}. */ | ||
public class TableConfigUtils { | ||
|
||
public static Configuration extractConfiguration(ReadableConfig readableConfig) { | ||
Configuration to = new Configuration(); | ||
copyConfiguration(readableConfig, to); | ||
return to; | ||
} | ||
|
||
private static void copyConfiguration(ReadableConfig from, Configuration to) { | ||
if (from instanceof Configuration) { | ||
to.addAll((Configuration) from); | ||
return; | ||
} | ||
|
||
if (!(from instanceof TableConfig)) { | ||
throw new RuntimeException("Unknown readableConfig type: " + from.getClass()); | ||
} | ||
|
||
TableConfig tableConfig = (TableConfig) from; | ||
|
||
// copy root configuration first | ||
copyConfiguration(tableConfig.getRootConfiguration(), to); | ||
|
||
// copy table configuration | ||
to.addAll(tableConfig.getConfiguration()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...k-common/src/main/java/org/apache/paimon/flink/utils/StreamExecutionEnvironmentUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.paimon.flink.utils; | ||
|
||
import org.apache.flink.configuration.ReadableConfig; | ||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; | ||
|
||
/** Utility methods for {@link StreamExecutionEnvironment}. */ | ||
public class StreamExecutionEnvironmentUtils { | ||
|
||
public static ReadableConfig getConfiguration(StreamExecutionEnvironment env) { | ||
return env.getConfiguration(); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...aimon-flink-common/src/main/java/org/apache/paimon/flink/utils/TableEnvironmentUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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.paimon.flink.utils; | ||
|
||
import org.apache.flink.api.dag.Transformation; | ||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.api.TableResult; | ||
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.List; | ||
|
||
/** Utility methods for {@link TableEnvironment} and its subclasses. */ | ||
public class TableEnvironmentUtils { | ||
|
||
/** | ||
* Invoke {@code TableEnvironmentImpl#executeInternal(List<Transformation<?>>, List<String>)} | ||
* from a {@link StreamTableEnvironment} instance through reflecting. | ||
*/ | ||
public static TableResult executeInternal( | ||
StreamTableEnvironment tEnv, | ||
List<Transformation<?>> transformations, | ||
List<String> sinkIdentifierNames) { | ||
Class<?> clazz = tEnv.getClass().getSuperclass().getSuperclass(); | ||
try { | ||
Method executeInternal = | ||
clazz.getDeclaredMethod("executeInternal", List.class, List.class); | ||
executeInternal.setAccessible(true); | ||
|
||
return (TableResult) executeInternal.invoke(tEnv, transformations, sinkIdentifierNames); | ||
} catch (NoSuchMethodException e) { | ||
throw new RuntimeException( | ||
"Failed to get 'TableEnvironmentImpl#executeInternal(List, List)' method " | ||
+ "from given StreamTableEnvironment instance by Java reflection. This is unexpected.", | ||
e); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
throw new RuntimeException( | ||
"Failed to invoke 'TableEnvironmentImpl#executeInternal(List, List)' method " | ||
+ "from given StreamTableEnvironment instance by Java reflection. This is unexpected.", | ||
e); | ||
} | ||
} | ||
} |