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


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java:
##########
@@ -2754,6 +2774,44 @@ static String resolveSpannerProjectId(SpannerConfig 
config) {
         : config.getProjectId().get();
   }
 
+  @VisibleForTesting
+  static void checkTvfExistence(DatabaseClient databaseClient, List<String> 
tvfNameList) {
+    if (tvfNameList == null || tvfNameList.isEmpty()) {
+      return;
+    }
+    try (ReadOnlyTransaction tx = databaseClient.readOnlyTransaction()) {
+      StringBuilder inClauseBuilder = new StringBuilder();
+      for (int i = 0; i < tvfNameList.size(); i++) {
+        inClauseBuilder
+            .append("'")
+            .append(PartitionMetadataDao.escapeTvfName(tvfNameList.get(i)))
+            .append("'");
+        if (i < tvfNameList.size() - 1) {
+          inClauseBuilder.append(", ");
+        }
+      }
+      String inClause = inClauseBuilder.toString();
+      // Note routine_type for GSQL is 'TABLE FUNCTION', for PostgreSQL is 
'FUNCTION'.
+      String query =
+          "SELECT routine_name FROM information_schema.routines WHERE 
routine_type LIKE '%FUNCTION' AND routine_name IN ("
+              + inClause
+              + ")";
+
+      Statement statement = Statement.newBuilder(query).build();
+      ResultSet resultSet = tx.executeQuery(statement);

Review Comment:
   done



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