diff --git a/flink-architecture-tests/pom.xml b/flink-architecture-tests/pom.xml index 7bc261e263697..5521684ee59ee 100644 --- a/flink-architecture-tests/pom.xml +++ b/flink-architecture-tests/pom.xml @@ -74,7 +74,7 @@ under the License. org.apache.flink - flink-sql-client_${scala.binary.version} + flink-table-common ${project.version} test @@ -102,7 +102,7 @@ under the License. org.apache.flink - flink-table-common + flink-table-runtime ${project.version} test @@ -116,7 +116,7 @@ under the License. org.apache.flink - flink-table-runtime + flink-sql-client ${project.version} test diff --git a/flink-architecture-tests/violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 b/flink-architecture-tests/violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 index 34b4b88ce8699..30a9de4ebc543 100644 --- a/flink-architecture-tests/violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 +++ b/flink-architecture-tests/violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 @@ -45,6 +45,9 @@ org.apache.flink.api.java.operators.IterativeDataSet.getAggregators(): Returned org.apache.flink.api.java.operators.ReduceOperator.setCombineHint(org.apache.flink.api.common.operators.base.ReduceOperatorBase$CombineHint): Argument leaf type org.apache.flink.api.common.operators.base.ReduceOperatorBase$CombineHint does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated org.apache.flink.api.java.typeutils.PojoTypeInfo.getPojoFieldAt(int): Returned leaf type org.apache.flink.api.java.typeutils.PojoField does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated org.apache.flink.api.java.typeutils.TupleTypeInfo.createSerializer(org.apache.flink.api.common.ExecutionConfig): Returned leaf type org.apache.flink.api.java.typeutils.runtime.TupleSerializer does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated +org.apache.flink.cep.functions.PatternProcessFunction.processMatch(java.util.Map, org.apache.flink.cep.functions.PatternProcessFunction$Context, org.apache.flink.util.Collector): Argument leaf type org.apache.flink.cep.functions.PatternProcessFunction$Context does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated +org.apache.flink.cep.functions.TimedOutPartialMatchHandler.processTimedOutMatch(java.util.Map, org.apache.flink.cep.functions.PatternProcessFunction$Context): Argument leaf type org.apache.flink.cep.functions.PatternProcessFunction$Context does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated +org.apache.flink.cep.pattern.conditions.IterativeCondition.filter(java.lang.Object, org.apache.flink.cep.pattern.conditions.IterativeCondition$Context): Argument leaf type org.apache.flink.cep.pattern.conditions.IterativeCondition$Context does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated org.apache.flink.client.program.StreamContextEnvironment.execute(org.apache.flink.streaming.api.graph.StreamGraph): Argument leaf type org.apache.flink.streaming.api.graph.StreamGraph does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated org.apache.flink.client.program.StreamContextEnvironment.executeAsync(org.apache.flink.streaming.api.graph.StreamGraph): Argument leaf type org.apache.flink.streaming.api.graph.StreamGraph does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated org.apache.flink.client.program.StreamContextEnvironment.setAsContext(org.apache.flink.core.execution.PipelineExecutorServiceLoader, org.apache.flink.configuration.Configuration, java.lang.ClassLoader, boolean, boolean): Argument leaf type org.apache.flink.core.execution.PipelineExecutorServiceLoader does not satisfy: reside outside of package 'org.apache.flink..' or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated diff --git a/flink-architecture-tests/violations/7602816f-5c01-4b7a-9e3e-235dfedec245 b/flink-architecture-tests/violations/7602816f-5c01-4b7a-9e3e-235dfedec245 index 2bd762c2de342..3e4b87803c275 100644 --- a/flink-architecture-tests/violations/7602816f-5c01-4b7a-9e3e-235dfedec245 +++ b/flink-architecture-tests/violations/7602816f-5c01-4b7a-9e3e-235dfedec245 @@ -317,4 +317,4 @@ org.apache.flink.streaming.api.windowing.triggers.TriggerResult does not satisfy org.apache.flink.streaming.api.windowing.windows.GlobalWindow$Serializer does not satisfy: annotated with @Internal or annotated with @Experimental or annotated with @PublicEvolving or annotated with @Public or annotated with @Deprecated org.apache.flink.streaming.api.windowing.windows.GlobalWindow$Serializer$GlobalWindowSerializerSnapshot does not satisfy: annotated with @Internal or annotated with @Experimental or annotated with @PublicEvolving or annotated with @Public or annotated with @Deprecated org.apache.flink.streaming.api.windowing.windows.TimeWindow$Serializer does not satisfy: annotated with @Internal or annotated with @Experimental or annotated with @PublicEvolving or annotated with @Public or annotated with @Deprecated -org.apache.flink.streaming.api.windowing.windows.TimeWindow$Serializer$TimeWindowSerializerSnapshot does not satisfy: annotated with @Internal or annotated with @Experimental or annotated with @PublicEvolving or annotated with @Public or annotated with @Deprecated +org.apache.flink.streaming.api.windowing.windows.TimeWindow$Serializer$TimeWindowSerializerSnapshot does not satisfy: annotated with @Internal or annotated with @Experimental or annotated with @PublicEvolving or annotated with @Public or annotated with @Deprecated \ No newline at end of file diff --git a/flink-architecture-tests/violations/e5126cae-f3fe-48aa-b6fb-60ae6cc3fcd5 b/flink-architecture-tests/violations/e5126cae-f3fe-48aa-b6fb-60ae6cc3fcd5 index 53f357a5b4193..43204b70221f2 100644 --- a/flink-architecture-tests/violations/e5126cae-f3fe-48aa-b6fb-60ae6cc3fcd5 +++ b/flink-architecture-tests/violations/e5126cae-f3fe-48aa-b6fb-60ae6cc3fcd5 @@ -2,6 +2,7 @@ Constructor (org.apache.flink.streaming.api.operators.AbstractStreamOperator, org.apache.flink.runtime.execution.Environment, java.util.Map)> calls method in (StreamingRuntimeContext.java:85) Constructor (org.apache.flink.streaming.api.operators.SourceOperator, java.util.function.Consumer, int, int)> calls method in (StreamTaskExternallyInducedSourceInput.java:39) Method calls method in (TupleSerializerSnapshot.java:70) +Method calls method in (LockableTypeSerializerSnapshot.java:60) Method calls method in (KafkaSourceReader.java:193) Method calls method in (OrcNoHiveShim.java:62) Method calls method in (BlobInputStream.java:127) @@ -9,14 +10,14 @@ Method calls Method calls method in (BlobOutputStream.java:155) Method calls method in (BlobServerConnection.java:200) Method calls method in (FileSystemBlobStore.java:122) -Method calls method in (CheckpointCoordinator.java:1735) -Method calls method in (Execution.java:974) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:67) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:79) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:93) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:61) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:73) -Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:86) +Method calls method in (CheckpointCoordinator.java:1737) +Method calls method in (Execution.java:983) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:78) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:90) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:104) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:72) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:84) +Method calls method in (EmbeddedHaServicesWithLeadershipControl.java:97) Method calls method in (ResourceManagerPartitionTrackerImpl.java:269) Method calls method in (RemoteInputChannel.java:336) Method calls method in (RemoteInputChannel.java:341) @@ -31,11 +32,11 @@ Method calls method in (WindowedStream.java:907) Method calls method in (InternalTimeServiceManagerImpl.java:249) Method calls method in (InternalTimeServiceManagerImpl.java:240) -Method calls method in (SourceOperator.java:250) -Method calls method in (SourceOperator.java:256) +Method calls method in (SourceOperator.java:252) +Method calls method in (SourceOperator.java:258) Method calls method in (FlinkKafkaProducer.java:1327) -Method calls method in (SourceOperatorStreamTask.java:72) -Method calls method in (StreamTask.java:801) -Method calls method in (StreamTask.java:796) +Method calls method in (SourceOperatorStreamTask.java:73) +Method calls method in (StreamTask.java:793) +Method calls method in (StreamTask.java:788) Method calls method in (MailboxExecutorImpl.java:63) Method calls method in (HiveParserDDLSemanticAnalyzer.java:271) \ No newline at end of file diff --git a/flink-dist/pom.xml b/flink-dist/pom.xml index f5f4779dd9ae8..11d7d3a726ef7 100644 --- a/flink-dist/pom.xml +++ b/flink-dist/pom.xml @@ -170,6 +170,45 @@ under the License. compile + + + + org.apache.flink + flink-table-api-java-uber + ${project.version} + provided + + + + org.apache.flink + flink-table-runtime + ${project.version} + provided + + + + org.apache.flink + flink-table-planner-loader + ${project.version} + provided + + + + + + org.apache.flink + flink-table-planner_${scala.binary.version} + ${project.version} + provided + + + + org.apache.flink + flink-sql-client + ${project.version} + provided + + + - ../flink-table/flink-table-uber/target/flink-table-uber_${scala.binary.version}-${project.version}.jar + ../flink-table/flink-table-api-java-uber/target/flink-table-api-java-uber-${project.version}.jar lib/ - flink-table_${scala.binary.version}-${project.version}.jar + flink-table-api-java-uber-${project.version}.jar + 0644 + + + ../flink-table/flink-table-runtime/target/flink-table-runtime-${project.version}.jar + lib/ + flink-table-runtime-${project.version}.jar + 0644 + + + ../flink-table/flink-table-planner-loader/target/flink-table-planner-loader-${project.version}.jar + lib/ + flink-table-planner-loader-${project.version}.jar + 0644 + + + + + ../flink-libraries/flink-cep/target/flink-cep-${project.version}.jar + lib/ + flink-cep-${project.version}.jar 0644 diff --git a/flink-dist/src/main/assemblies/opt.xml b/flink-dist/src/main/assemblies/opt.xml index 66ee0fc71ccf2..83209489bef78 100644 --- a/flink-dist/src/main/assemblies/opt.xml +++ b/flink-dist/src/main/assemblies/opt.xml @@ -30,13 +30,6 @@ - - ../flink-libraries/flink-cep/target/flink-cep-${project.version}.jar - opt/ - flink-cep-${project.version}.jar - 0644 - - ../flink-libraries/flink-cep-scala/target/flink-cep-scala_${scala.binary.version}-${project.version}.jar opt/ @@ -59,11 +52,17 @@ 0644 - + + + ../flink-table/flink-table-planner/target/flink-table-planner_${scala.binary.version}-${project.version}.jar + opt/ + flink-table-planner_${scala.binary.version}-${project.version}.jar + 0644 + - ../flink-table/flink-sql-client/target/flink-sql-client_${scala.binary.version}-${project.version}.jar + ../flink-table/flink-sql-client/target/flink-sql-client-${project.version}.jar opt/ - flink-sql-client_${scala.binary.version}-${project.version}.jar + flink-sql-client-${project.version}.jar 0644 diff --git a/flink-docs/pom.xml b/flink-docs/pom.xml index f4d540d32c327..79cf618f155ad 100644 --- a/flink-docs/pom.xml +++ b/flink-docs/pom.xml @@ -71,7 +71,7 @@ under the License. org.apache.flink - flink-sql-client_${scala.binary.version} + flink-sql-client ${project.version} diff --git a/flink-end-to-end-tests/flink-sql-client-test/pom.xml b/flink-end-to-end-tests/flink-sql-client-test/pom.xml index ee6195fb3f15d..8a6233c0108cb 100644 --- a/flink-end-to-end-tests/flink-sql-client-test/pom.xml +++ b/flink-end-to-end-tests/flink-sql-client-test/pom.xml @@ -141,7 +141,7 @@ under the License. ${project.build.directory}/sql-jars - diff --git a/flink-end-to-end-tests/flink-stream-sql-test/pom.xml b/flink-end-to-end-tests/flink-stream-sql-test/pom.xml index d25e479fba5b1..a34ac2298cbbb 100644 --- a/flink-end-to-end-tests/flink-stream-sql-test/pom.xml +++ b/flink-end-to-end-tests/flink-stream-sql-test/pom.xml @@ -30,19 +30,12 @@ 4.0.0 - flink-stream-sql-test_${scala.binary.version} + flink-stream-sql-test Flink : E2E Tests : Stream SQL jar - - org.apache.flink - flink-streaming-scala_${scala.binary.version} - ${project.version} - provided - - - + org.apache.flink flink-table-api-java-bridge diff --git a/flink-end-to-end-tests/flink-tpcds-test/pom.xml b/flink-end-to-end-tests/flink-tpcds-test/pom.xml index e8e6a575cfab4..dbcfb2ecb0f3a 100644 --- a/flink-end-to-end-tests/flink-tpcds-test/pom.xml +++ b/flink-end-to-end-tests/flink-tpcds-test/pom.xml @@ -38,7 +38,19 @@ under the License. org.apache.flink - flink-table-planner_${scala.binary.version} + flink-streaming-java + ${project.version} + provided + + + org.apache.flink + flink-table-api-java-bridge + ${project.version} + provided + + + org.apache.flink + flink-table-planner-loader ${project.version} provided diff --git a/flink-examples/flink-examples-table/pom.xml b/flink-examples/flink-examples-table/pom.xml index 99200a5e56387..bb45932297273 100644 --- a/flink-examples/flink-examples-table/pom.xml +++ b/flink-examples/flink-examples-table/pom.xml @@ -34,21 +34,22 @@ under the License. jar - - + org.apache.flink - flink-table-api-java-bridge + flink-clients ${project.version} + + org.apache.flink - flink-table-api-scala-bridge_${scala.binary.version} + flink-table-api-java-bridge ${project.version} org.apache.flink - flink-table-planner_${scala.binary.version} + flink-table-api-scala-bridge_${scala.binary.version} ${project.version} @@ -64,22 +65,22 @@ under the License. ${project.version} - + org.apache.flink - flink-streaming-scala_${scala.binary.version} + flink-test-utils ${project.version} + test org.apache.flink - flink-clients + flink-table-runtime ${project.version} + test - - org.apache.flink - flink-test-utils + flink-table-planner-loader ${project.version} test diff --git a/flink-python/apache-flink-libraries/setup.py b/flink-python/apache-flink-libraries/setup.py index d2b9521f65ac7..d269626280c72 100644 --- a/flink-python/apache-flink-libraries/setup.py +++ b/flink-python/apache-flink-libraries/setup.py @@ -118,7 +118,7 @@ def find_file_path(pattern): OPT_PYTHON_JAR_NAME = os.path.basename( find_file_path(os.path.join(OPT_PATH, "flink-python_*.jar"))) OPT_SQL_CLIENT_JAR_NAME = os.path.basename( - find_file_path(os.path.join(OPT_PATH, "flink-sql-client_*.jar"))) + find_file_path(os.path.join(OPT_PATH, "flink-sql-client*.jar"))) LICENSES_PATH = os.path.join(FLINK_HOME, "licenses") PLUGINS_PATH = os.path.join(FLINK_HOME, "plugins") SCRIPTS_PATH = os.path.join(FLINK_HOME, "bin") diff --git a/flink-table/README.md b/flink-table/README.md new file mode 100644 index 0000000000000..b6766736a7377 --- /dev/null +++ b/flink-table/README.md @@ -0,0 +1,67 @@ +# Table API & SQL + +Apache Flink features two relational APIs - the Table API and SQL - for unified stream and batch processing. +The Table API is a language-integrated query API for Java, Scala, and Python that allows the composition of queries from relational operators such as selection, filter, and join in a very intuitive way. + +This documentation is intended for contributors of the table modules, and not for users. +If you want to use Table API & SQL, check out the [documentation](https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/overview/). + +## Modules + +### Common + +* `flink-table-common`: + * Type system definition + * UDF stack and built-in function definitions + * Internal data definitions + * Extension points for catalogs, formats, connectors + * Core APIs for extension points such as `Schema` + * Utilities to deal with type system, internal data types and printing + +### API + +* `flink-table-api-java`: + * Java APIs for Table API and SQL + * Package `org.apache.flink.table.delegation`, which serves as entrypoint for all planner capabilities +* `flink-table-api-scala`: Scala APIs for Table API and SQL +* `flink-table-api-bridge-base`: Base classes for APIs to bridge between Table API and DataStream API +* `flink-table-api-java-bridge`: + * Java APIs to bridge between Table API and DataStream API + * Connectors that are developed using DataStream API, usually need to depend only on this module. +* `flink-table-api-scala-bridge`: Scala APIs to bridge between Table API and DataStream API +* `flink-table-api-java-uber`: + * Uber JAR bundling `flink-table-common` and all the Java API modules, including the bridging to DataStream API and 3rd party dependencies. + * This module is intended to be used by the flink-dist, rather than from the users directly. + +### Runtime + +* `flink-table-code-splitter`: Tool to split generated Java code so that each method does not exceed the limit of 64KB. +* `flink-table-runtime`: + * Operator implementations + * Built-in functions implementations + * Type system implementation, including readers/writers, converters and utilities + * Raw format + * The produced jar includes all the classes from this module and `flink-table-code-splitter`, including 3rd party dependencies + +### Parser and planner + +* `flink-sql-parser`: Default ANSI SQL parser implementation +* `flink-sql-parser-hive`: Hive SQL dialect parser implementation +* `flink-table-planner`: + * AST and Semantic tree + * SQL validator + * Query planner, optimizer and rules implementation + * Code generator + * Two jars are produced: one doesn't have any classifier and bundles all the classes from this module together with the two parsers, including 3rd party dependencies, while the other jar, classified as `loader-bundle`, extends the first jar including scala dependencies. +* `flink-table-planner-loader`: Loader for `flink-table-planner` that loads the planner in a separate classpath, isolating the Scala version used to compile the planner. + +### SQL client + +* `flink-sql-client`: CLI tool to submit queries to a Flink cluster + +### Notes + +No module except `flink-table-planner` should depend on `flink-table-runtime` in production classpath, +and similarly no module should depend on `flink-table-planner` or `flink-table-planner-loader` in production classpath. +For testing, you should depend on `flink-table-planner-loader` and `flink-table-runtime`. +These are already shipped by the Flink distribution. diff --git a/flink-table/flink-sql-client/pom.xml b/flink-table/flink-sql-client/pom.xml index ba4315711c474..fbd61f6bb1665 100644 --- a/flink-table/flink-sql-client/pom.xml +++ b/flink-table/flink-sql-client/pom.xml @@ -27,7 +27,7 @@ under the License. .. - flink-sql-client_${scala.binary.version} + flink-sql-client Flink : Table : SQL Client This module contains the SQL Client for exploring and @@ -38,58 +38,20 @@ under the License. - - - - - org.apache.flink - flink-core - ${project.version} - - + org.apache.flink flink-clients ${project.version} - - org.apache.flink - flink-streaming-scala_${scala.binary.version} - ${project.version} - - - - org.apache.flink - flink-table-common - ${project.version} - - - - org.apache.flink - flink-table-api-java - ${project.version} - - org.apache.flink flink-table-api-java-bridge ${project.version} - - org.apache.flink - flink-table-planner_${scala.binary.version} - ${project.version} - - - - org.apache.flink - flink-table-runtime - ${project.version} - - org.jline @@ -153,8 +115,7 @@ under the License. org.apache.flink flink-connector-hive_${scala.binary.version} ${project.version} - provided - true + test org.apache.hadoop @@ -172,10 +133,18 @@ under the License. org.apache.flink - flink-table-api-scala-bridge_${scala.binary.version} + flink-table-runtime ${project.version} test + + + org.apache.flink + flink-table-planner_${scala.binary.version} + ${project.version} + test + + org.apache.flink flink-table-planner_${scala.binary.version} @@ -504,7 +473,7 @@ under the License. org.apache.hadoop hadoop-mapreduce-client-core ${hivemetastore.hadoop.version} - provided + test org.apache.curator diff --git a/flink-table/flink-table-uber/pom.xml b/flink-table/flink-table-api-java-uber/pom.xml similarity index 61% rename from flink-table/flink-table-uber/pom.xml rename to flink-table/flink-table-api-java-uber/pom.xml index 6b80c11fce57f..e0f68eb3db000 100644 --- a/flink-table/flink-table-uber/pom.xml +++ b/flink-table/flink-table-api-java-uber/pom.xml @@ -27,12 +27,11 @@ under the License. .. - flink-table-uber_${scala.binary.version} - Flink : Table : Uber + flink-table-api-java-uber + Flink : Table : API Java Uber - This module contains the entire Table/SQL distribution for writing table programs - within the table ecosystem or between other Flink APIs. Users can either use the - Scala or Java programming language. + This module contains all the Java APIs of the Table/SQL ecosystem for writing table programs + within the table ecosystem or between other Flink APIs. jar @@ -43,26 +42,11 @@ under the License. flink-table-common ${project.version} - - org.apache.flink - flink-sql-parser - ${project.version} - - - org.apache.flink - flink-sql-parser-hive - ${project.version} - org.apache.flink flink-table-api-java ${project.version} - - org.apache.flink - flink-table-api-scala_${scala.binary.version} - ${project.version} - org.apache.flink flink-table-api-bridge-base @@ -73,26 +57,6 @@ under the License. flink-table-api-java-bridge ${project.version} - - org.apache.flink - flink-table-api-scala-bridge_${scala.binary.version} - ${project.version} - - - org.apache.flink - flink-table-planner_${scala.binary.version} - ${project.version} - - - org.apache.flink - flink-table-runtime - ${project.version} - - - org.apache.flink - flink-cep - ${project.version} - @@ -109,18 +73,25 @@ under the License. shade + + + com.ibm.icu:icu4j + + + LICENSE + + + - + org.apache.flink:flink-table-common org.apache.flink:flink-table-api-java - org.apache.flink:flink-table-api-scala_${scala.binary.version} org.apache.flink:flink-table-api-bridge-base org.apache.flink:flink-table-api-java-bridge - org.apache.flink:flink-table-api-scala-bridge_${scala.binary.version} - org.apache.flink:flink-table-planner_${scala.binary.version} - org.apache.flink:flink-table-runtime - org.apache.flink:flink-cep + + + com.ibm.icu:icu4j diff --git a/flink-table/flink-table-api-java-uber/src/main/resources/META-INF/NOTICE b/flink-table/flink-table-api-java-uber/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000000..44440c1ca96a1 --- /dev/null +++ b/flink-table/flink-table-api-java-uber/src/main/resources/META-INF/NOTICE @@ -0,0 +1,10 @@ +flink-table-api-uber +Copyright 2014-2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +This project bundles the following dependencies under the ICU license. +See bundled license files for details + +- com.ibm.icu:icu4j:67.1 diff --git a/flink-table/flink-table-planner/src/main/resources/META-INF/licenses/LICENSE.icu4j b/flink-table/flink-table-api-java-uber/src/main/resources/META-INF/licenses/LICENSE.icu4j similarity index 100% rename from flink-table/flink-table-planner/src/main/resources/META-INF/licenses/LICENSE.icu4j rename to flink-table/flink-table-api-java-uber/src/main/resources/META-INF/licenses/LICENSE.icu4j diff --git a/flink-table/flink-table-common/pom.xml b/flink-table/flink-table-common/pom.xml index 17a7c5ab2a922..8e8ff8fe284fe 100644 --- a/flink-table/flink-table-common/pom.xml +++ b/flink-table/flink-table-common/pom.xml @@ -56,8 +56,6 @@ under the License. com.ibm.icu icu4j 67.1 - - provided diff --git a/flink-table/flink-table-planner-loader/pom.xml b/flink-table/flink-table-planner-loader/pom.xml new file mode 100644 index 0000000000000..dfd03a4acf478 --- /dev/null +++ b/flink-table/flink-table-planner-loader/pom.xml @@ -0,0 +1,163 @@ + + + + + + 4.0.0 + + + org.apache.flink + flink-table + 1.15-SNAPSHOT + .. + + + flink-table-planner-loader + Flink : Table : Planner Loader + jar + + This module contains the mechanism for loading flink-table-planner through a separate classloader. + This allows arbitrary Scala versions in the classpath, hiding the Scala version used by the planner. + + + + + + org.apache.flink + flink-table-api-bridge-base + ${project.version} + + + + + org.apache.flink + flink-test-utils-junit + + + + + org.apache.flink + flink-table-planner_${scala.binary.version} + ${project.version} + + runtime + + true + + + + * + * + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + org.apache.flink:flink-table-planner_${scala.binary.version} + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-table-planner-jars + prepare-package + + copy + + + + + org.apache.flink + flink-table-planner_${scala.binary.version} + ${project.version} + loader-bundle + jar + true + flink-table-planner.jar + + + ${project.build.directory}/classes + + + + + + org.apache.maven.plugins + maven-shade-plugin + + + shade-flink + package + + shade + + + + + org.apache.flink:flink-table-planner + + META-INF/NOTICE + META-INF/licenses/** + + + + + + + org.apache.flink:flink-table-planner + + + + + + + + + + diff --git a/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/BaseDelegateFactory.java b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/BaseDelegateFactory.java new file mode 100644 index 0000000000000..e00506b9b4947 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/BaseDelegateFactory.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.table.factories.Factory; + +import java.util.Set; + +/** Base class for all factory delegates. */ +abstract class BaseDelegateFactory implements Factory { + + final DELEGATE delegate; + + protected BaseDelegateFactory(DELEGATE delegate) { + this.delegate = delegate; + } + + @Override + public String factoryIdentifier() { + return delegate.factoryIdentifier(); + } + + @Override + public Set> requiredOptions() { + return delegate.requiredOptions(); + } + + @Override + public Set> optionalOptions() { + return delegate.optionalOptions(); + } +} diff --git a/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExecutorFactory.java b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExecutorFactory.java new file mode 100644 index 0000000000000..6d08304a03166 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExecutorFactory.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.delegation.Executor; +import org.apache.flink.table.delegation.ExecutorFactory; +import org.apache.flink.table.delegation.StreamExecutorFactory; + +/** Delegate of {@link ExecutorFactory}. */ +@Internal +public class DelegateExecutorFactory extends BaseDelegateFactory + implements StreamExecutorFactory { + + public DelegateExecutorFactory() { + super((StreamExecutorFactory) PlannerModule.getInstance().loadExecutorFactory()); + } + + @Override + public Executor create(Configuration configuration) { + return delegate.create(configuration); + } + + public Executor create(StreamExecutionEnvironment streamExecutionEnvironment) { + return delegate.create(streamExecutionEnvironment); + } +} diff --git a/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExpressionParserFactory.java b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExpressionParserFactory.java new file mode 100644 index 0000000000000..8597ce9afa68e --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegateExpressionParserFactory.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.table.delegation.ExpressionParser; +import org.apache.flink.table.delegation.ExpressionParserFactory; + +/** Delegate of {@link ExpressionParserFactory}. */ +@Internal +public class DelegateExpressionParserFactory extends BaseDelegateFactory + implements ExpressionParserFactory { + + public DelegateExpressionParserFactory() { + super(PlannerModule.getInstance().loadExpressionParserFactory()); + } + + @Override + public ExpressionParser create() { + return delegate.create(); + } +} diff --git a/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegatePlannerFactory.java b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegatePlannerFactory.java new file mode 100644 index 0000000000000..32a5eeafa9782 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/DelegatePlannerFactory.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.table.delegation.Planner; +import org.apache.flink.table.delegation.PlannerFactory; + +/** Delegate of {@link PlannerFactory}. */ +@Internal +public class DelegatePlannerFactory extends BaseDelegateFactory + implements PlannerFactory { + + public DelegatePlannerFactory() { + super(PlannerModule.getInstance().loadPlannerFactory()); + } + + @Override + public Planner create(Context context) { + return delegate.create(context); + } +} diff --git a/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/PlannerModule.java b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/PlannerModule.java new file mode 100644 index 0000000000000..2630fc9106dd5 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/java/org/apache/flink/table/planner/loader/PlannerModule.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ConfigurationUtils; +import org.apache.flink.configuration.CoreOptions; +import org.apache.flink.core.classloading.ComponentClassLoader; +import org.apache.flink.core.classloading.SubmoduleClassLoader; +import org.apache.flink.table.api.TableException; +import org.apache.flink.table.delegation.ExecutorFactory; +import org.apache.flink.table.delegation.ExpressionParserFactory; +import org.apache.flink.table.delegation.PlannerFactory; +import org.apache.flink.table.factories.FactoryUtil; +import org.apache.flink.util.IOUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.UUID; +import java.util.stream.Stream; + +/** + * Module holder that loads the flink-table-planner module in a separate classpath. + * + *

This loader expects the flink-table-planner jar to be accessible via {@link + * ClassLoader#getResource(String)}. It will extract the jar into a temporary directory and create a + * new {@link SubmoduleClassLoader} to load the various planner factories from that jar. + */ +class PlannerModule { + + /** + * The name of the table planner dependency jar, bundled with flink-table-planner-loader module + * artifact. + */ + static final String FLINK_TABLE_PLANNER_FAT_JAR = "flink-table-planner.jar"; + + static final String HINT_USAGE = + "mvn clean package -pl flink-table/flink-table-planner,flink-table/flink-table-planner-loader -DskipTests"; + + private final ClassLoader submoduleClassLoader; + + private PlannerModule() { + try { + final ClassLoader flinkClassLoader = PlannerModule.class.getClassLoader(); + + final Path tmpDirectory = + Paths.get(ConfigurationUtils.parseTempDirectories(new Configuration())[0]); + Files.createDirectories(tmpDirectory); + final Path tempFile = + Files.createFile( + tmpDirectory.resolve( + "flink-table-planner_" + UUID.randomUUID() + ".jar")); + + final InputStream resourceStream = + flinkClassLoader.getResourceAsStream(FLINK_TABLE_PLANNER_FAT_JAR); + if (resourceStream == null) { + throw new TableException( + String.format( + "Flink Table planner could not be found. If this happened while running a test in the IDE, " + + "run '%s' on the command-line, " + + "or add a test dependency on the flink-table-planner-loader test-jar.", + HINT_USAGE)); + } + + IOUtils.copyBytes(resourceStream, Files.newOutputStream(tempFile)); + + String[] ownerClassPath = + Stream.concat( + Arrays.stream(CoreOptions.PARENT_FIRST_LOGGING_PATTERNS), + Stream.of( + // These packages are shipped either by + // flink-table-runtime or flink-dist itself + "org.codehaus.janino", + "org.codehaus.commons", + "org.apache.commons.lang3", + // Used by org.reflections + "javassist")) + .toArray(String[]::new); + String[] componentClassPath = new String[] {"org.apache.flink"}; + + this.submoduleClassLoader = + new ComponentClassLoader( + new URL[] {tempFile.toUri().toURL()}, + flinkClassLoader, + ownerClassPath, + componentClassPath); + } catch (IOException e) { + throw new TableException( + "Could not initialize the table planner components loader.", e); + } + } + + // Singleton lazy initialization + + private static class PlannerComponentsHolder { + private static final PlannerModule INSTANCE = new PlannerModule(); + } + + public static PlannerModule getInstance() { + return PlannerComponentsHolder.INSTANCE; + } + + // load methods for various components provided by the planner + + public ExecutorFactory loadExecutorFactory() { + return FactoryUtil.discoverFactory( + this.submoduleClassLoader, + ExecutorFactory.class, + ExecutorFactory.DEFAULT_IDENTIFIER); + } + + public PlannerFactory loadPlannerFactory() { + return FactoryUtil.discoverFactory( + this.submoduleClassLoader, PlannerFactory.class, PlannerFactory.DEFAULT_IDENTIFIER); + } + + public ExpressionParserFactory loadExpressionParserFactory() { + return FactoryUtil.discoverFactory( + this.submoduleClassLoader, + ExpressionParserFactory.class, + ExpressionParserFactory.DEFAULT_IDENTIFIER); + } +} diff --git a/flink-table/flink-table-planner-loader/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory b/flink-table/flink-table-planner-loader/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory new file mode 100644 index 0000000000000..880ba99c48558 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory @@ -0,0 +1,18 @@ +# 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. + +org.apache.flink.table.planner.loader.DelegateExecutorFactory +org.apache.flink.table.planner.loader.DelegateExpressionParserFactory +org.apache.flink.table.planner.loader.DelegatePlannerFactory diff --git a/flink-table/flink-table-planner-loader/src/test/java/org/apache/flink/table/planner/loader/LoaderITCase.java b/flink-table/flink-table-planner-loader/src/test/java/org/apache/flink/table/planner/loader/LoaderITCase.java new file mode 100644 index 0000000000000..52574bb4e9b02 --- /dev/null +++ b/flink-table/flink-table-planner-loader/src/test/java/org/apache/flink/table/planner/loader/LoaderITCase.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.loader; + +import org.apache.flink.table.delegation.ExecutorFactory; +import org.apache.flink.table.delegation.ExpressionParserFactory; +import org.apache.flink.table.delegation.PlannerFactory; +import org.apache.flink.table.factories.FactoryUtil; +import org.apache.flink.util.TestLogger; + +import org.junit.jupiter.api.Test; + +import static org.apache.flink.table.planner.loader.PlannerModule.FLINK_TABLE_PLANNER_FAT_JAR; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for the services loaded through {@link PlannerModule}. + * + *

This must be an ITCase so that it runs after the 'package' phase of maven. Otherwise, the + * flink-table-planner jar will not be available. + * + *

This test might fail in your IDE if the flink-table-planner-loader module is wrongly configure + * to include flink-table-planner in the test classpath. + */ +public class LoaderITCase extends TestLogger { + + @Test + public void testExecutorFactory() { + assertThat( + DelegateExecutorFactory.class + .getClassLoader() + .getResourceAsStream(FLINK_TABLE_PLANNER_FAT_JAR)) + .isNotNull(); + + ExecutorFactory executorFactory = + FactoryUtil.discoverFactory( + LoaderITCase.class.getClassLoader(), + ExecutorFactory.class, + ExecutorFactory.DEFAULT_IDENTIFIER); + + assertThat(executorFactory).isNotNull().isInstanceOf(DelegateExecutorFactory.class); + assertThat(executorFactory.factoryIdentifier()) + .isEqualTo(ExecutorFactory.DEFAULT_IDENTIFIER); + } + + @Test + public void testPlannerFactory() { + assertThat( + DelegatePlannerFactory.class + .getClassLoader() + .getResourceAsStream(FLINK_TABLE_PLANNER_FAT_JAR)) + .isNotNull(); + + PlannerFactory plannerFactory = + FactoryUtil.discoverFactory( + LoaderITCase.class.getClassLoader(), + PlannerFactory.class, + PlannerFactory.DEFAULT_IDENTIFIER); + + assertThat(plannerFactory).isNotNull().isInstanceOf(DelegatePlannerFactory.class); + assertThat(plannerFactory.factoryIdentifier()).isEqualTo(PlannerFactory.DEFAULT_IDENTIFIER); + } + + @Test + public void testExpressionParserFactory() { + assertThat( + DelegateExpressionParserFactory.class + .getClassLoader() + .getResourceAsStream(FLINK_TABLE_PLANNER_FAT_JAR)) + .isNotNull(); + + ExpressionParserFactory expressionParserFactory = + FactoryUtil.discoverFactory( + LoaderITCase.class.getClassLoader(), + ExpressionParserFactory.class, + ExpressionParserFactory.DEFAULT_IDENTIFIER); + + assertThat(expressionParserFactory) + .isNotNull() + .isInstanceOf(DelegateExpressionParserFactory.class); + assertThat(expressionParserFactory.factoryIdentifier()) + .isEqualTo(ExpressionParserFactory.DEFAULT_IDENTIFIER); + } +} diff --git a/flink-table/flink-table-planner/pom.xml b/flink-table/flink-table-planner/pom.xml index d89cfc33c5c33..f57850d351a93 100644 --- a/flink-table/flink-table-planner/pom.xml +++ b/flink-table/flink-table-planner/pom.xml @@ -39,8 +39,7 @@ under the License. jar - + com.google.guava guava @@ -49,37 +48,28 @@ under the License. org.codehaus.janino commons-compiler - + org.codehaus.janino janino - - + org.apache.flink - flink-table-common + flink-table-api-java-bridge ${project.version} - - org.apache.flink - flink-table-api-java - ${project.version} - + org.apache.flink - flink-table-api-bridge-base + flink-scala_${scala.binary.version} ${project.version} - - org.apache.flink - flink-table-api-java-bridge - ${project.version} - + org.apache.flink @@ -92,7 +82,6 @@ under the License. - org.apache.flink flink-sql-parser-hive @@ -105,23 +94,15 @@ under the License. + + org.apache.flink flink-table-runtime ${project.version} - - org.apache.flink - flink-scala_${scala.binary.version} - ${project.version} - - - - org.apache.flink - flink-streaming-scala_${scala.binary.version} - ${project.version} - + org.apache.flink @@ -130,8 +111,10 @@ under the License. provided - + + + org.apache.calcite calcite-core @@ -185,6 +168,10 @@ under the License. org.apache.commons commons-dbcp2 + + org.apache.commons + commons-lang3 + com.fasterxml.jackson.dataformat jackson-dataformat-yaml @@ -205,20 +192,32 @@ under the License. - - com.ibm.icu - icu4j - 67.1 + + org.scala-lang.modules + scala-parser-combinators_${scala.binary.version} - - org.scala-lang.modules - scala-parser-combinators_${scala.binary.version} + + org.reflections + reflections + 0.9.10 + compile + + + com.google.code.findbugs + annotations + + + com.google.guava + guava + + - + + org.apache.flink flink-test-utils @@ -226,30 +225,31 @@ under the License. test + + org.apache.flink - flink-core + flink-table-api-scala_${scala.binary.version} ${project.version} - test-jar test - org.apache.flink - flink-table-api-scala_${scala.binary.version} + flink-table-api-scala-bridge_${scala.binary.version} ${project.version} test org.apache.flink - flink-table-api-scala-bridge_${scala.binary.version} + flink-core ${project.version} + test-jar test - + org.apache.flink flink-tests ${project.version} @@ -296,31 +296,13 @@ under the License. test - + org.apache.flink flink-connector-files ${project.version} test - - - - org.reflections - reflections - 0.9.10 - - - com.google.code.findbugs - annotations - - - com.google.guava - guava - - - compile - @@ -356,103 +338,130 @@ under the License. org.apache.maven.plugins maven-shade-plugin + + + true + ${project.basedir}/target/dependency-reduced-pom.xml + + + *:* + + + org-apache-calcite-jdbc.properties + common.proto + requests.proto + responses.proto + codegen/** + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + META-INF/services/java.sql.Driver + META-INF/versions/11/module-info.class + + LICENSE + + + + + + org.apache.calcite:* + org.apache.calcite.avatica:* + + + com.esri.geometry:esri-geometry-api + com.google.guava:guava + com.google.guava:failureaccess + commons-codec:commons-codec + commons-io:commons-io + + + org.apache.flink:flink-sql-parser + org.apache.flink:flink-sql-parser-hive + + + org.scala-lang.modules:scala-parser-combinators_${scala.binary.version} + + + org.reflections:reflections + + + + + + + + + com.google + org.apache.flink.calcite.shaded.com.google + + + com.jayway + org.apache.flink.calcite.shaded.com.jayway + + + com.fasterxml + org.apache.flink.shaded.jackson2.com.fasterxml + + + org.apache.commons.codec + org.apache.flink.calcite.shaded.org.apache.commons.codec + + + org.apache.commons.io + org.apache.flink.calcite.shaded.org.apache.commons.io + + + + org.reflections + org.apache.flink.table.shaded.org.reflections + + + + + com.ibm.icu + org.apache.flink.table.shaded.com.ibm.icu + + + + shade-flink + + none + + + + shade-loader-bundle + package + + shade + - - - *:* - - - org-apache-calcite-jdbc.properties - common.proto - requests.proto - responses.proto - codegen/** - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - META-INF/services/java.sql.Driver - META-INF/versions/11/module-info.class - - LICENSE - - - + true + loader-bundle - org.apache.calcite:* - org.apache.calcite.avatica:* - - - com.esri.geometry:esri-geometry-api - com.google.guava:guava - com.google.guava:failureaccess - commons-codec:commons-codec - commons-io:commons-io - - - org.apache.flink:flink-sql-parser - org.apache.flink:flink-sql-parser-hive - - - org.codehaus.janino:* - org.apache.flink:flink-table-code-splitter - - - com.ibm.icu:icu4j - - - org.scala-lang.modules:scala-parser-combinators_${scala.binary.version} - - org.reflections:reflections + + org.scala-lang:* + org.apache.flink:flink-scala_${scala.binary.version} - - - - - - - com.google - org.apache.flink.calcite.shaded.com.google - - - - com.jayway - org.apache.flink.calcite.shaded.com.jayway - - - - com.fasterxml - org.apache.flink.shaded.jackson2.com.fasterxml - - - org.apache.commons.codec - org.apache.flink.calcite.shaded.org.apache.commons.codec - - - org.apache.commons.io - org.apache.flink.calcite.shaded.org.apache.commons.io - - - - - - - - org.reflections - org.apache.flink.table.shaded.org.reflections - - - + + + + shade-distribution + package + + shade + + + false diff --git a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java index ced64c8bf86e6..34bd234e6d941 100644 --- a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java +++ b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/JsonSerdeUtil.java @@ -53,6 +53,8 @@ public static ObjectMapper createObjectMapper(SerdeContext serdeCtx) { null, // JsonFactory null, // DefaultSerializerProvider ctx); + mapper.setTypeFactory( + mapper.getTypeFactory().withClassLoader(JsonSerdeUtil.class.getClassLoader())); mapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, false); ctx.setObjectMapper(mapper); return mapper; diff --git a/flink-table/flink-table-planner/src/main/resources/META-INF/NOTICE b/flink-table/flink-table-planner/src/main/resources/META-INF/NOTICE index 2b53463f2986c..0696cfe825d2c 100644 --- a/flink-table/flink-table-planner/src/main/resources/META-INF/NOTICE +++ b/flink-table/flink-table-planner/src/main/resources/META-INF/NOTICE @@ -16,17 +16,6 @@ This project bundles the following dependencies under the Apache Software Licens - commons-codec:commons-codec:1.15 - commons-io:commons-io:2.11.0 -This project bundles the following dependencies under the BSD license. -See bundled license files for details - -- org.codehaus.janino:janino:3.0.11 -- org.codehaus.janino:commons-compiler:3.0.11 - -This project bundles the following dependencies under the ICU license. -See bundled license files for details - -- com.ibm.icu:icu4j:67.1 - This project bundles the following dependencies under the WTFPL license. See bundled license files for details diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala index a4e735103992e..f18183e69e202 100644 --- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala +++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala @@ -23,7 +23,7 @@ import org.apache.flink.api.dag.Transformation import org.apache.flink.configuration.ReadableConfig import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment import org.apache.flink.table.api.config.{ExecutionConfigOptions, TableConfigOptions} -import org.apache.flink.table.api.{PlannerType, SqlDialect, TableConfig, TableEnvironment, TableException} +import org.apache.flink.table.api._ import org.apache.flink.table.catalog._ import org.apache.flink.table.connector.sink.DynamicTableSink import org.apache.flink.table.delegation.{Executor, Parser, Planner} @@ -161,8 +161,8 @@ abstract class PlannerBase( def createNewParser: Parser = { val factoryIdentifier = getTableConfig.getSqlDialect.name().toLowerCase - val parserFactory = FactoryUtil.discoverFactory(Thread.currentThread.getContextClassLoader, - classOf[ParserFactory], factoryIdentifier) + val parserFactory = FactoryUtil.discoverFactory( + getClass.getClassLoader, classOf[ParserFactory], factoryIdentifier) val context = new DefaultParserContext(catalogManager, plannerContext) parserFactory.create(context) diff --git a/flink-table/flink-table-runtime/pom.xml b/flink-table/flink-table-runtime/pom.xml index 0c85dcc7653db..3a116fd8abc38 100644 --- a/flink-table/flink-table-runtime/pom.xml +++ b/flink-table/flink-table-runtime/pom.xml @@ -37,9 +37,7 @@ under the License. jar - - - + org.apache.flink flink-table-common @@ -64,27 +62,24 @@ under the License. ${project.version} - - org.apache.flink - flink-streaming-java - ${project.version} - provided - - + org.apache.flink flink-cep ${project.version} - provided + org.codehaus.janino janino - ${janino.version} + + + org.codehaus.janino + commons-compiler - + com.jayway.jsonpath @@ -92,7 +87,7 @@ under the License. ${jsonpath.version} - + org.apache.flink @@ -143,6 +138,7 @@ under the License. org.apache.maven.plugins maven-shade-plugin + shade-flink package @@ -153,9 +149,12 @@ under the License. com.jayway.jsonpath:json-path + org.codehaus.janino:* + org.apache.flink:flink-table-code-splitter + com.jayway org.apache.flink.calcite.shaded.com.jayway diff --git a/flink-table/flink-table-runtime/src/main/resources/META-INF/NOTICE b/flink-table/flink-table-runtime/src/main/resources/META-INF/NOTICE index 33fe52a325b32..0b85bd761b2b7 100644 --- a/flink-table/flink-table-runtime/src/main/resources/META-INF/NOTICE +++ b/flink-table/flink-table-runtime/src/main/resources/META-INF/NOTICE @@ -7,3 +7,5 @@ The Apache Software Foundation (http://www.apache.org/). This project bundles the following dependencies under the Apache Software License 2.0. (http://www.apache.org/licenses/LICENSE-2.0.txt) - com.jayway.jsonpath:json-path:2.6.0 +- org.codehaus.janino:janino:3.0.11 +- org.codehaus.janino:commons-compiler:3.0.11 diff --git a/flink-table/flink-table-planner/src/main/resources/META-INF/licenses/LICENSE.janino b/flink-table/flink-table-runtime/src/main/resources/META-INF/licenses/LICENSE.janino similarity index 100% rename from flink-table/flink-table-planner/src/main/resources/META-INF/licenses/LICENSE.janino rename to flink-table/flink-table-runtime/src/main/resources/META-INF/licenses/LICENSE.janino diff --git a/flink-table/pom.xml b/flink-table/pom.xml index 850931ecc692b..b8605d2ed7970 100644 --- a/flink-table/pom.xml +++ b/flink-table/pom.xml @@ -39,9 +39,10 @@ under the License. flink-table-api-bridge-base flink-table-api-java-bridge flink-table-api-scala-bridge + flink-table-api-java-uber flink-table-planner + flink-table-planner-loader flink-table-runtime - flink-table-uber flink-sql-client flink-sql-parser flink-sql-parser-hive diff --git a/tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/suffixcheck/ScalaSuffixChecker.java b/tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/suffixcheck/ScalaSuffixChecker.java index 239bdd5bff0c4..1a00dfb538b4b 100644 --- a/tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/suffixcheck/ScalaSuffixChecker.java +++ b/tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/suffixcheck/ScalaSuffixChecker.java @@ -27,6 +27,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -52,7 +53,15 @@ public class ScalaSuffixChecker { // [INFO] +- org.scala-lang:scala-reflect:jar:2.11.12:test private static final Pattern scalaSuffixPattern = Pattern.compile("_2.1[0-9]"); - private static final String AKKA_RPC_MODULE_NAME = "flink-rpc-akka"; + private static final Set EXCLUDED_MODULES = + new HashSet<>( + Arrays.asList( + // we ignore flink-rpc-akka because it is loaded through a separate + // class loader + "flink-rpc-akka", + // we ignore flink-table-planner-loader because it loads the planner + // through a different classpath + "flink-table-planner-loader")); public static void main(String[] args) throws IOException { if (args.length < 2) { @@ -95,9 +104,7 @@ private static ParseResult parseMavenOutput(final Path path) throws IOException final Matcher matcher = moduleNamePattern.matcher(line); if (matcher.matches()) { final String moduleName = stripScalaSuffix(matcher.group(1)); - // we ignored flink-rpc-akka because it is loaded through a separate class - // loader - if (moduleName.equals(AKKA_RPC_MODULE_NAME)) { + if (isExcluded(moduleName)) { continue; } LOG.trace("Parsing module '{}'.", moduleName); @@ -112,12 +119,12 @@ private static ParseResult parseMavenOutput(final Path path) throws IOException final boolean isTestDependency = line.endsWith(":test"); // we ignored flink-rpc-akka because it is loaded through a separate class // loader - final boolean isFlinkAkkaRpc = line.contains(AKKA_RPC_MODULE_NAME); + final boolean isExcluded = isExcluded(line); LOG.trace("\tline:{}", line); LOG.trace("\t\tdepends-on-scala:{}", dependsOnScala); LOG.trace("\t\tis-test-dependency:{}", isTestDependency); - LOG.trace("\t\tis-flink-rpc-akka:{}", isFlinkAkkaRpc); - if (dependsOnScala && !isTestDependency && !isFlinkAkkaRpc) { + LOG.trace("\t\tis-excluded:{}", isExcluded); + if (dependsOnScala && !isTestDependency && !isExcluded) { LOG.trace("\t\tOutbreak detected at {}!", moduleName); infected = true; } @@ -242,6 +249,10 @@ private static Collection checkModules( return violations; } + private static boolean isExcluded(String line) { + return EXCLUDED_MODULES.stream().anyMatch(line::contains); + } + private static class ParseResult { private final Set cleanModules; diff --git a/tools/ci/stage.sh b/tools/ci/stage.sh index 882660994dd67..894977fa3ee5f 100755 --- a/tools/ci/stage.sh +++ b/tools/ci/stage.sh @@ -66,6 +66,7 @@ flink-table/flink-table-api-java-bridge,\ flink-table/flink-table-api-scala-bridge,\ flink-table/flink-sql-client,\ flink-table/flink-table-planner,\ +flink-table/flink-table-planner-loader,\ flink-table/flink-table-runtime,\ flink-table/flink-table-code-splitter"