You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "ChengJie1053 (via GitHub)" <gi...@apache.org> on 2023/05/31 08:36:36 UTC

[GitHub] [linkis] ChengJie1053 commented on a diff in pull request #4588: Generate spark sql from kafka es mongo

ChengJie1053 commented on code in PR #4588:
URL: https://github.com/apache/linkis/pull/4588#discussion_r1211295273


##########
linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/main/java/org/apache/linkis/metadata/query/server/service/impl/MetadataQueryServiceImpl.java:
##########
@@ -379,32 +381,126 @@ public GenerateSqlInfo getSparkSqlByDsNameAndEnvId(
     DsInfoResponse dsInfoResponse =
         queryDataSourceInfoByNameAndEnvId(dataSourceName, system, userName, envId);
 
-    if (StringUtils.isNotBlank(dsInfoResponse.getDsType())
-        && CacheConfiguration.MYSQL_RELATIONSHIP_LIST
-            .getValue()
-            .contains(dsInfoResponse.getDsType())) {
-      List<MetaColumnInfo> columns =
-          invokeMetaMethod(
-              dsInfoResponse.getDsType(),
-              "getColumns",
-              new Object[] {
-                dsInfoResponse.getCreator(), dsInfoResponse.getParams(), database, table
-              },
-              List.class);
-
-      String sqlConnectUrl =
-          invokeMetaMethod(
-              dsInfoResponse.getDsType(),
-              "getSqlConnectUrl",
-              new Object[] {dsInfoResponse.getCreator(), dsInfoResponse.getParams()},
-              String.class);
-
-      return getSparkSqlByJdbc(database, table, dsInfoResponse.getParams(), columns, sqlConnectUrl);
+    if (StringUtils.isNotBlank(dsInfoResponse.getDsType())) {
+      List<MetaColumnInfo> columns = new ArrayList<>();
+      try {
+        columns =
+            invokeMetaMethod(
+                dsInfoResponse.getDsType(),
+                "getColumns",
+                new Object[] {
+                  dsInfoResponse.getCreator(),
+                  dsInfoResponse.getParams(),
+                  database,
+                  dsInfoResponse.getDsType().equalsIgnoreCase("elasticsearch") ? "_doc" : table
+                },
+                List.class);
+      } catch (Exception e) {
+        logger.warn("Fail to get Sql columns(获取字段列表失败)");
+      }
+      if (CacheConfiguration.MYSQL_RELATIONSHIP_LIST
+          .getValue()
+          .contains(dsInfoResponse.getDsType())) {
+        String sqlConnectUrl =
+            invokeMetaMethod(
+                dsInfoResponse.getDsType(),
+                "getSqlConnectUrl",
+                new Object[] {dsInfoResponse.getCreator(), dsInfoResponse.getParams()},
+                String.class);
+
+        return getSparkSqlByJdbc(
+            database, table, dsInfoResponse.getParams(), columns, sqlConnectUrl);
+      } else if (dsInfoResponse.getDsType().equalsIgnoreCase("kafka")) {

Review Comment:
   Ok, thank you for reviewing the code



-- 
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: notifications-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org