maytasm commented on a change in pull request #11227:
URL: https://github.com/apache/druid/pull/11227#discussion_r629652513
##########
File path:
server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java
##########
@@ -1423,4 +1424,40 @@ public boolean insertDataSourceMetadata(String
dataSource, DataSourceMetadata me
.execute()
);
}
+
+ @Override
+ public int removeDataSourceMetadataOlderThan(long timestamp, @Nullable
Set<String> excludeDatasources)
+ {
+ DateTime dateTime = DateTimes.utc(timestamp);
+ List<String> datasources = connector.getDBI().withHandle(
+ handle -> handle
+ .createQuery(
+ StringUtils.format(
+ "SELECT dataSource FROM %1$s WHERE created_date < '%2$s'",
+ dbTables.getDataSourceTable(),
+ dateTime.toString()
+ )
+ )
+ .mapTo(String.class)
+ .list()
+ );
+ return connector.getDBI().withHandle(
+ handle -> {
+ final PreparedBatch batch = handle.prepareBatch(
+ StringUtils.format(
+ "DELETE FROM %1$s WHERE dataSource = :dataSource AND
created_date < '%2$s'",
Review comment:
Also moved the filtering of the datasources to outside the handle block.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]