You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/06 07:48:07 UTC
[GitHub] [flink] dawidwys opened a new pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
dawidwys opened a new pull request #12826:
URL: https://github.com/apache/flink/pull/12826
## What is the purpose of the change
Fix creating a catalog with DDL when the catalog implementation comes from a user jar.
## Brief change log
* Make user classloader available in TableEnvironmentImpl
* Move instantiation of the catalog to the point when CreateCatalogOperation is executed
* Use the user classloader when creating a catalog from DDL
## Verifying this change
* Added test testCreateCatalogFromUserClassLoader
* Try creating a catalog from a sql-client with the catalog dependencies are passed with the `-j` parameter.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no**)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dawidwys commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452106967
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
I don't think so. The problem is the line in `SqlToOperationConverter:557`.
```
final CatalogFactory factory =
TableFactoryService.find(CatalogFactory.class, properties, this.getClass().getClassLoader());
```
It is using the class classloader, not the context classloader. I could've just changed that to use the context classloader, but I found it wrong that the catalog is instantiated in `SqlToOperationConverter` and it would not use the classloader provided in `EnvironmentSettings` in the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] godfreyhe commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452121304
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
you are right.`SqlToOperationConverter:557` is the root cause. I find the test case does not covert the full change path (not the whole commit), such as I remove the line in `TableEnvironmentImpl#1052`,
```
final CatalogFactory factory = TableFactoryService.find(
CatalogFactory.class,
properties);
```
The test case can also run successfully. Do we need build `StreamExecutionEnvironmentImpl` with user classloader directly to verify the change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] godfreyhe commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452224521
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
ok, let FLINK-15635 fully support this feature
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dawidwys merged pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
dawidwys merged pull request #12826:
URL: https://github.com/apache/flink/pull/12826
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12826:
URL: https://github.com/apache/flink/pull/12826#issuecomment-654075595
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit 0691185bcfe408b32b0f61a2bb2313c04c69b0e2 (Mon Jul 06 07:50:57 UTC 2020)
**Warnings:**
* **1 pom.xml files were touched**: Check for build and licensing issues.
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dawidwys commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452106967
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
I don't think so. The problem is the line in `SqlToOperationConverter:557`.
```
final CatalogFactory factory =
TableFactoryService.find(CatalogFactory.class, properties, this.getClass().getClassLoader());
```
It is using the class classloader, not the context classloader. I could've just changed that to use the context classloader, but I found it wrong that the catalog is instantiated in `SqlToOperationConverter`. Moreover it would not use the classloader provided in `EnvironmentSettings` in the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12826:
URL: https://github.com/apache/flink/pull/12826#issuecomment-654081532
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4259",
"triggerID" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0691185bcfe408b32b0f61a2bb2313c04c69b0e2 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4259)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12826:
URL: https://github.com/apache/flink/pull/12826#issuecomment-654081532
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0691185bcfe408b32b0f61a2bb2313c04c69b0e2 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12826:
URL: https://github.com/apache/flink/pull/12826#issuecomment-654081532
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4259",
"triggerID" : "0691185bcfe408b32b0f61a2bb2313c04c69b0e2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0691185bcfe408b32b0f61a2bb2313c04c69b0e2 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4259)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] godfreyhe commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452103391
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
This case can run successfully even without the commit `[FLINK-18419] Create catalog in TableEnvironment using user ClassLoader`. Because `TemporaryClassLoaderContext.of` method sets the user classloader to the current thread, and `TableFactoryService#discoverFactories` method will use the classloader in the current thread to find factories.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452120466
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
I can reproduce the exception after reverting the fixing changes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452120466
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
I can reproduce the exception after revert the fixing changes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dawidwys commented on a change in pull request #12826: [FLINK-18419] Create catalog in TableEnvironment using user classloader
Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12826:
URL: https://github.com/apache/flink/pull/12826#discussion_r452161206
##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/CatalogITCase.java
##########
@@ -61,9 +70,54 @@ public void testDropCatalog() {
assertFalse(tableEnv.getCatalog(name).isPresent());
}
+ @Test
+ public void testCreateCatalogFromUserClassLoader() throws Exception {
+ final String className = "UserCatalogFactory";
+ URLClassLoader classLoader = ClassLoaderUtils.withRoot(temporaryFolder.newFolder())
+ .addResource("META-INF/services/org.apache.flink.table.factories.TableFactory", "UserCatalogFactory")
+ .addClass(
+ className,
+ "import org.apache.flink.table.catalog.GenericInMemoryCatalog;\n" +
+ "import org.apache.flink.table.factories.CatalogFactory;\n" +
+ "import java.util.Collections;\n" +
+ "import org.apache.flink.table.catalog.Catalog;\n" +
+ "import java.util.HashMap;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "\tpublic class UserCatalogFactory implements CatalogFactory {\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Catalog createCatalog(\n" +
+ "\t\t\t\tString name,\n" +
+ "\t\t\t\tMap<String, String> properties) {\n" +
+ "\t\t\treturn new GenericInMemoryCatalog(name);\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic Map<String, String> requiredContext() {\n" +
+ "\t\t\tHashMap<String, String> hashMap = new HashMap<>();\n" +
+ "\t\t\thashMap.put(\"type\", \"userCatalog\");\n" +
+ "\t\t\treturn hashMap;\n" +
+ "\t\t}\n" +
+ "\n" +
+ "\t\t@Override\n" +
+ "\t\tpublic List<String> supportedProperties() {\n" +
+ "\t\t\treturn Collections.emptyList();\n" +
+ "\t\t}\n" +
+ "\t}"
+ ).build();
+
+ try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
Review comment:
I see your point. Nevertheless your approach would not test a different code path. That the context classloader is used. This behaviour is important from the sql-client perspective.
I lean slightly towards the current approach, as it uses only the user facing APIs. It tests what is expected in sql-client. Imo, a test that the classloader from EnvironmentSettings is used should be part of https://issues.apache.org/jira/browse/FLINK-15635
WDYT?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org