mirror of https://github.com/apache/druid.git
Fix SQL Server select query in createInactiveStatusesSinceQuery() method. (#5901)
* Fix SQL Server select query in createInactiveStatusesSinceQuery() method. SQL server does not support LIMIT N in select queries. Instead it has TOP N to limiting number of query results. And TOP N is already added in the select statement as per maxNumStatuses value. * Add parentheses for TOP in SELECT statement as SQL Servers no longer support TOP without parentheses.
This commit is contained in:
parent
b6c957b0d2
commit
867f6a9e2b
|
@ -49,7 +49,7 @@ public class SQLServerMetadataStorageActionHandler<EntryType, StatusType, LogTyp
|
|||
Handle handle, DateTime timestamp, @Nullable Integer maxNumStatuses, @Nullable String datasource
|
||||
)
|
||||
{
|
||||
String sql = maxNumStatuses == null ? "SELECT " : "SELECT TOP :n ";
|
||||
String sql = maxNumStatuses == null ? "SELECT " : "SELECT TOP (:n) ";
|
||||
|
||||
sql += StringUtils.format(
|
||||
" id, "
|
||||
|
@ -64,9 +64,7 @@ public class SQLServerMetadataStorageActionHandler<EntryType, StatusType, LogTyp
|
|||
+ "ORDER BY created_date DESC",
|
||||
getEntryTable()
|
||||
);
|
||||
if (maxNumStatuses != null) {
|
||||
sql += " LIMIT :n";
|
||||
}
|
||||
|
||||
Query<Map<String, Object>> query = handle.createQuery(sql).bind("start", timestamp.toString());
|
||||
|
||||
if (maxNumStatuses != null) {
|
||||
|
|
Loading…
Reference in New Issue