tianz101 commented on code in PR #38167:
URL: https://github.com/apache/beam/pull/38167#discussion_r3112925718
##########
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:
Yes, this is a good idea and I will do that and refresh the commit. Thanks.
--
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]