fsk119 commented on code in PR #20402: URL: https://github.com/apache/flink/pull/20402#discussion_r935272524
########## flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/endpoint/hive/HiveServer2EndpointITCase.java: ########## @@ -123,6 +133,56 @@ public void testGetException() throws Exception { "Session '%s' does not exist", sessionHandle))); } + @Test + public void testCancelOperation() throws Exception { + TCLIService.Client client = createClient(); + TOpenSessionReq openSessionReq = new TOpenSessionReq(); + TOpenSessionResp openSessionResp = client.OpenSession(openSessionReq); + SessionHandle sessionHandle = + ThriftObjectConversions.toSessionHandle(openSessionResp.getSessionHandle()); + + OperationHandle operationHandle = + SQL_GATEWAY_SERVICE_EXTENSION + .getService() + .executeStatement( + sessionHandle, + "select 1", + 0, + Configuration.fromMap(Collections.emptyMap())); Review Comment: It's not stable to do this. The main thread is send the cancel request when the operation is finished. ########## flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/endpoint/hive/HiveServer2EndpointITCase.java: ########## @@ -123,6 +133,56 @@ public void testGetException() throws Exception { "Session '%s' does not exist", sessionHandle))); } + @Test + public void testCancelOperation() throws Exception { + TCLIService.Client client = createClient(); + TOpenSessionReq openSessionReq = new TOpenSessionReq(); + TOpenSessionResp openSessionResp = client.OpenSession(openSessionReq); + SessionHandle sessionHandle = + ThriftObjectConversions.toSessionHandle(openSessionResp.getSessionHandle()); + + OperationHandle operationHandle = + SQL_GATEWAY_SERVICE_EXTENSION + .getService() + .executeStatement( + sessionHandle, + "select 1", + 0, + Configuration.fromMap(Collections.emptyMap())); + TOperationHandle tOperationHandle = + toTOperationHandle(sessionHandle, operationHandle, OperationType.EXECUTE_STATEMENT); + TCancelOperationReq tCancelOperationReq = new TCancelOperationReq(tOperationHandle); + TCancelOperationResp tCancelOperationResp = + ENDPOINT_EXTENSION.getEndpoint().CancelOperation(tCancelOperationReq); + assertThat(tCancelOperationResp.getStatus().getStatusCode()) + .isEqualTo(TStatusCode.SUCCESS_STATUS); Review Comment: We also need to verify the operation is canceled. ########## flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/endpoint/hive/HiveServer2EndpointITCase.java: ########## @@ -123,6 +133,56 @@ public void testGetException() throws Exception { "Session '%s' does not exist", sessionHandle))); } + @Test + public void testCancelOperation() throws Exception { + TCLIService.Client client = createClient(); + TOpenSessionReq openSessionReq = new TOpenSessionReq(); + TOpenSessionResp openSessionResp = client.OpenSession(openSessionReq); + SessionHandle sessionHandle = + ThriftObjectConversions.toSessionHandle(openSessionResp.getSessionHandle()); + + OperationHandle operationHandle = + SQL_GATEWAY_SERVICE_EXTENSION + .getService() + .executeStatement( + sessionHandle, + "select 1", + 0, + Configuration.fromMap(Collections.emptyMap())); + TOperationHandle tOperationHandle = + toTOperationHandle(sessionHandle, operationHandle, OperationType.EXECUTE_STATEMENT); + TCancelOperationReq tCancelOperationReq = new TCancelOperationReq(tOperationHandle); + TCancelOperationResp tCancelOperationResp = + ENDPOINT_EXTENSION.getEndpoint().CancelOperation(tCancelOperationReq); + assertThat(tCancelOperationResp.getStatus().getStatusCode()) + .isEqualTo(TStatusCode.SUCCESS_STATUS); + } + + @Test + public void testCloseOperation() throws Exception { + TCLIService.Client client = createClient(); + TOpenSessionReq openSessionReq = new TOpenSessionReq(); + TOpenSessionResp openSessionResp = client.OpenSession(openSessionReq); + SessionHandle sessionHandle = Review Comment: Actually we can use SqlGatewayService#openSession. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org