chenxuesdu commented on code in PR #38167:
URL: https://github.com/apache/beam/pull/38167#discussion_r3096851436


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java:
##########
@@ -2754,6 +2774,50 @@ static String resolveSpannerProjectId(SpannerConfig 
config) {
         : config.getProjectId().get();
   }
 
+  @VisibleForTesting
+  static void checkTvfExistence(DatabaseClient databaseClient, List<String> 
tvfNameList) {
+    if (tvfNameList == null || tvfNameList.isEmpty()) {
+      return;
+    }
+    Dialect dialect = databaseClient.getDialect();
+    try (ReadOnlyTransaction tx = databaseClient.readOnlyTransaction()) {
+      StringBuilder sql =
+          new StringBuilder(
+              "SELECT routine_name FROM information_schema.routines WHERE 
routine_type LIKE '%FUNCTION' AND routine_name IN (");
+      for (int i = 0; i < tvfNameList.size(); i++) {
+        if (dialect == Dialect.POSTGRESQL) {
+          sql.append("$").append(i + 1);
+        } else {
+          sql.append("@p").append(i);
+        }
+        if (i < tvfNameList.size() - 1) {
+          sql.append(", ");
+        }
+      }
+      sql.append(")");
+      Statement.Builder builder = Statement.newBuilder(sql.toString());
+      for (int i = 0; i < tvfNameList.size(); i++) {

Review Comment:
   If we call escapeTvfName for each tvf before storing in tvfNameList and 
store them, we don't need to escape again when use the tvf name. Is that right?



-- 
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]

Reply via email to