goiri commented on code in PR #4846:
URL: https://github.com/apache/hadoop/pull/4846#discussion_r966535217


##########
hadoop-yarn-project/hadoop-yarn/bin/FederationStateStore/MySQL/FederationStateStoreStoredProcs.sql:
##########
@@ -122,10 +122,29 @@ BEGIN
    WHERE applicationId = applicationID_IN;
 END //
 
-CREATE PROCEDURE sp_getApplicationsHomeSubCluster()
-BEGIN
-   SELECT applicationId, homeSubCluster
-   FROM applicationsHomeSubCluster;
+CREATE PROCEDURE sp_getApplicationsHomeSubCluster(IN limit_IN int, IN 
homeSubCluster_IN varchar(256))
+BEGIN
+   SELECT
+       t4.applicationId,
+       t4.createTime,
+       t4.homeSubCluster,
+       t4.row_num
+    FROM (
+         SELECT
+             t2.applicationId,
+             t2.createTime,
+             t2.homeSubCluster,
+             @row_num := @row_num + 1 AS row_num
+         FROM (
+             SELECT
+             t.applicationId,
+             t.homeSubCluster,
+             t.createTime
+             FROM applicationshomesubcluster AS t
+             WHERE ( CASE WHEN t.homeSubCluster_IN IS NULL THEN 1 = 1 WHEN 
t.homeSubCluster_IN IS NOT NULL THEN homeSubCluster = homeSubCluster_IN END )

Review Comment:
   Wow! Is this the cleanest way to return the top N records?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to