v2/gcs-to-sourcedb/src/main/java/com/google/cloud/teleport/v2/templates/dao/SpannerDao.java [359:389]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public boolean doesIdExist(String id) {

    DatabaseClient databaseClient = spannerAccessor.getDatabaseClient();
    Statement statement;
    if (isPostgres) {
      String statementStr = "SELECT window_seen from " + dataSeenTableName + " where id=$1";
      statement = Statement.newBuilder(statementStr).bind("p1").to(id).build();

    } else {
      String statementStr = "SELECT window_seen from " + dataSeenTableName + " where id=@id";
      statement = Statement.newBuilder(statementStr).bind("id").to(id).build();
    }
    ResultSet resultSet = null;
    try (ReadOnlyTransaction tx = databaseClient.singleUseReadOnlyTransaction()) {
      resultSet = tx.executeQuery(statement);

      if (resultSet.next()) {
        return true;
      }
    } catch (Exception e) {
      LOG.info("The " + dataSeenTableName + " table could not be read.");
      // throw original exception for caller to make decision
      throw e;
    } finally {
      if (resultSet != null) {
        resultSet.close();
      }
    }

    return false;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



v2/spanner-change-streams-to-sharded-file-sink/src/main/java/com/google/cloud/teleport/v2/templates/utils/SpannerDao.java [454:484]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public boolean doesIdExist(String id) {

    DatabaseClient databaseClient = spannerAccessor.getDatabaseClient();
    Statement statement;
    if (isPostgres) {
      String statementStr = "SELECT window_seen from " + dataSeenTableName + " where id=$1";
      statement = Statement.newBuilder(statementStr).bind("p1").to(id).build();

    } else {
      String statementStr = "SELECT window_seen from " + dataSeenTableName + " where id=@id";
      statement = Statement.newBuilder(statementStr).bind("id").to(id).build();
    }
    ResultSet resultSet = null;
    try (ReadOnlyTransaction tx = databaseClient.singleUseReadOnlyTransaction()) {
      resultSet = tx.executeQuery(statement);
      if (resultSet.next()) {
        return true;
      }
    } catch (Exception e) {
      LOG.info("The " + dataSeenTableName + " table could not be read. ");
      // We need to throw the original exception such that the caller can
      // look at SpannerException class to take decision
      throw e;
    } finally {
      if (resultSet != null) {
        resultSet.close();
      }
    }

    return false;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



