Skip to content

Commit

Permalink
[FLINK-29857][hive] Set default value for GetInfoResp
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzelin authored and fsk119 committed Nov 10, 2022
1 parent 421f057 commit 194df8d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ public TGetInfoResp GetInfo(TGetInfoReq tGetInfoReq) throws TException {
resp.setInfoValue(tInfoValue);
} catch (Throwable t) {
LOG.error("Failed to GetInfo.", t);
// InfoValue must be set because the hive service requires it.
resp.setInfoValue(TGetInfoValue.lenValue(0));
resp.setStatus(toTStatus(t));
}
return resp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
import org.apache.hive.service.rpc.thrift.TExecuteStatementResp;
import org.apache.hive.service.rpc.thrift.TFetchOrientation;
import org.apache.hive.service.rpc.thrift.TFetchResultsReq;
import org.apache.hive.service.rpc.thrift.TGetInfoReq;
import org.apache.hive.service.rpc.thrift.TGetInfoResp;
import org.apache.hive.service.rpc.thrift.TGetInfoType;
import org.apache.hive.service.rpc.thrift.TGetOperationStatusReq;
import org.apache.hive.service.rpc.thrift.TOpenSessionReq;
import org.apache.hive.service.rpc.thrift.TOpenSessionResp;
Expand Down Expand Up @@ -595,6 +598,28 @@ public void testGetInfo() throws Exception {
}
}

@Test
public void testUnknownGetInfoType() throws Exception {
TCLIService.Client client = createClient();
TOpenSessionReq openSessionReq = new TOpenSessionReq();
TOpenSessionResp openSessionResp = client.OpenSession(openSessionReq);
TSessionHandle tSessionHandle = openSessionResp.getSessionHandle();

// send GetInfoReq using a GetInfoType which is unknown to HiveServer2 endpoint
TGetInfoReq getInfoReq =
new TGetInfoReq(tSessionHandle, TGetInfoType.CLI_MAX_IDENTIFIER_LEN);
TGetInfoResp getInfoResp = client.GetInfo(getInfoReq);
assertThat(getInfoResp.getStatus().getStatusCode()).isEqualTo(TStatusCode.ERROR_STATUS);

try (Connection connection = ENDPOINT_EXTENSION.getConnection()) {
DatabaseMetaData metaData = connection.getMetaData();
connection.createStatement().execute("CREATE SCHEMA test;");

assertThat(collectAndCompact(metaData.getSchemas("hive", null), 2))
.contains(Arrays.asList("test", "hive"));
}
}

@Test
public void testExecuteStatementInSyncMode() throws Exception {
TCLIService.Client client = createClient();
Expand Down

0 comments on commit 194df8d

Please sign in to comment.