legendtkl commented on code in PR #1850:
URL:
https://github.com/apache/incubator-seatunnel/pull/1850#discussion_r870373473
##########
seatunnel-core/seatunnel-core-flink-sql/src/main/java/org/apache/seatunnel/core/sql/job/Executor.java:
##########
@@ -75,12 +116,65 @@ private static StatementSet handleStatements(String
workFlowContent, StreamTable
if (op instanceof CatalogSinkModifyOperation) {
statementSet.addInsertSql(stmt);
} else {
+ if (op instanceof CreateTableOperation) {
+ String connectorType = ((CreateTableOperation)
op).getCatalogTable().getOptions().get(CONNECTOR_IDENTIFIER);
+ loadConnector(connectorType, executionEnvConfiguration);
+ }
+
tEnv.executeSql(stmt);
}
}
return statementSet;
}
+ private static void loadConnector(String connectorType, Configuration
configuration) {
+ Iterator<Factory> factories = ServiceLoader.load(Factory.class,
CLASSLOADER).iterator();
+ while (factories.hasNext()) {
+ Factory factory = factories.next();
+
+ /**
+ * Handle for two cases:
+ * 1. Flink built-in connectors.
+ * 2. Connectors have been placed in classpath.
+ */
+ if (factory.factoryIdentifier().equals(connectorType)) {
+ return;
+ }
+ }
+
+ Common.setDeployMode(DeployMode.CLIENT.getName());
+ File connectorDir =
Common.connectorJarDir(SQL_CONNECTOR_PREFIX).toFile();
+ if (!connectorDir.exists() || connectorDir.listFiles() == null) {
+ return;
+ }
+
+ Optional<File> connectorFile = Arrays.stream(connectorDir.listFiles())
+ .filter(file -> file.getName().startsWith(CONNECTOR_JAR_PREFIX +
connectorType))
+ .findFirst();
+
+ if (connectorFile.isPresent()) {
+ // handleStatements need this.
+ CLASSLOADER.addJar(connectorFile.get().toPath());
Review Comment:
Now I build the connector jars following the rule: one connector type
correspond to one jar.
But you're right, let me add a log message and think about how to handle it
gracefully in the long term.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]