zabetak commented on a change in pull request #3156:
URL: https://github.com/apache/hive/pull/3156#discussion_r840394149



##########
File path: 
service/src/test/org/apache/hive/service/cli/operation/TestQueryLifeTimeHooksWithSQLOperation.java
##########
@@ -110,6 +118,45 @@ public void afterExecution(QueryLifeTimeHookContext ctx, 
boolean hasError) {
       assertNull(ctx.getHookContext().getException());
       assertNotNull(ctx.getHookContext().getQueryInfo());
       assertNotNull(ctx.getHookContext().getQueryInfo().getQueryDisplay());
+      assertQueryId(ctx.getQueryId());
     }
   }
+
+  /**
+   * Asserts that the specified query id exists and has the expected prefix 
and size.
+   *
+   * <p>
+   * A query id looks like below:
+   * <pre>
+   *   username_20220330093338_dab90f30-5e79-463d-8359-0d2fff57effa
+   * </pre>
+   * and we can accurately predict how the prefix should look like. T
+   * </p>
+   *
+   * @param actualQueryId the query id to verify
+   */
+  private static void assertQueryId(String actualQueryId) {
+    assertNotNull(actualQueryId);
+    String expectedIdPrefix = makeQueryIdStablePrefix();
+    String actualIdPrefix = actualQueryId.substring(0, 
expectedIdPrefix.length());
+    assertEquals(expectedIdPrefix, actualIdPrefix);
+    assertEquals(expectedIdPrefix.length() + 41, actualQueryId.length());
+  }
+
+  /**
+   * Makes a query id prefix that is stable for an hour. The prefix changes 
every hour but this is enough to guarantee

Review comment:
       @kasakrisz Thanks for pointing out the `hive.query.id` property, I 
wasn't aware of it. It seems that if we have this property then we can obtain 
the queryId in before/after hook methods by querying the configuration. 
Apparently we don't necessarily need the new API introduced in this PR (apart 
from convenience) so I am inclined to close this without merging. WDYT? 




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