Source:
<code>private void deleteData(SchemaBuilder schemaBuilder, long scnTimestamp) throws SQLException { String viewName = schemaBuilder.getEntityTenantViewName(); LOGGER.debug(String.format("Deleting from view :- " + viewName)); Properties props = new Properties(); props.setProperty("CurrentSCN", Long.toString(scnTimestamp)); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); try (Connection deleteConnection = DriverManager.getConnection(tenantConnectUrl, props); final Statement statement = deleteConnection.createStatement()) { deleteConnection.setAutoCommit(true); final String deleteIfExpiredStatement = String.format("select * from %s", viewName); Preconditions.checkNotNull(deleteIfExpiredStatement); final PhoenixStatement pstmt = statement.unwrap(PhoenixStatement.class); final QueryPlan queryPlan = pstmt.optimizeQuery(deleteIfExpiredStatement); final Scan scan = queryPlan.getContext().getScan(); PTable table = PhoenixRuntime.getTable(deleteConnection, schemaBuilder.getDataOptions().getTenantId(), viewName); byte[] emptyColumnFamilyName = SchemaUtil.getEmptyColumnFamily(table); byte[] emptyColumnName = table.getEncodingScheme() == PTable.QualifierEncodingScheme.NON_ENCODED_QUALIFIERS ? QueryConstants.EMPTY_COLUMN_BYTES : table.getEncodingScheme().encode(QueryConstants.ENCODED_EMPTY_COLUMN_NAME); scan.setAttribute(BaseScannerRegionObserver.EMPTY_COLUMN_FAMILY_NAME, emptyColumnFamilyName); scan.setAttribute(BaseScannerRegionObserver.EMPTY_COLUMN_QUALIFIER_NAME, emptyColumnName); scan.setAttribute(BaseScannerRegionObserver.DELETE_VIEW_TTL_EXPIRED, PDataType.TRUE_BYTES); scan.setAttribute(BaseScannerRegionObserver.MASK_VIEW_TTL_EXPIRED, PDataType.FALSE_BYTES); scan.setAttribute(BaseScannerRegionObserver.VIEW_TTL, Bytes.toBytes(Long.valueOf(table.getViewTTL()))); PhoenixResultSet rs = pstmt.newResultSet(queryPlan.iterator(), queryPlan.getProjector(), queryPlan.getContext()); <START> if (rs.next()) { <END> LOGGER.debug(String.format("Number of deleted rows :- " + rs.getString(1))); } } }</code><technical_language>need logs in test.</technical_language>

Target:
private void deleteData(SchemaBuilder schemaBuilder, long scnTimestamp) throws SQLException { String viewName = schemaBuilder.getEntityTenantViewName(); Properties props = new Properties(); props.setProperty("CurrentSCN", Long.toString(scnTimestamp)); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); try (Connection deleteConnection = DriverManager.getConnection(tenantConnectUrl, props); final Statement statement = deleteConnection.createStatement()) { deleteConnection.setAutoCommit(true); final String deleteIfExpiredStatement = String.format("select * from %s", viewName); Preconditions.checkNotNull(deleteIfExpiredStatement); final PhoenixStatement pstmt = statement.unwrap(PhoenixStatement.class); final QueryPlan queryPlan = pstmt.optimizeQuery(deleteIfExpiredStatement); final Scan scan = queryPlan.getContext().getScan(); PTable table = PhoenixRuntime.getTable(deleteConnection, schemaBuilder.getDataOptions().getTenantId(), viewName); byte[] emptyColumnFamilyName = SchemaUtil.getEmptyColumnFamily(table); byte[] emptyColumnName = table.getEncodingScheme() == PTable.QualifierEncodingScheme.NON_ENCODED_QUALIFIERS ? QueryConstants.EMPTY_COLUMN_BYTES : table.getEncodingScheme().encode(QueryConstants.ENCODED_EMPTY_COLUMN_NAME); scan.setAttribute(BaseScannerRegionObserver.EMPTY_COLUMN_FAMILY_NAME, emptyColumnFamilyName); scan.setAttribute(BaseScannerRegionObserver.EMPTY_COLUMN_QUALIFIER_NAME, emptyColumnName); scan.setAttribute(BaseScannerRegionObserver.DELETE_VIEW_TTL_EXPIRED, PDataType.TRUE_BYTES); scan.setAttribute(BaseScannerRegionObserver.MASK_VIEW_TTL_EXPIRED, PDataType.FALSE_BYTES); scan.setAttribute(BaseScannerRegionObserver.VIEW_TTL, Bytes.toBytes(Long.valueOf(table.getViewTTL()))); PhoenixResultSet rs = pstmt.newResultSet(queryPlan.iterator(), queryPlan.getProjector(), queryPlan.getContext()); } }