@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
private List<ColumnDesc> getResultSchemaInternal(OperationHandle operationHandle) throws SQLException { ImmutableList.Builder<ColumnDesc> listBuilder = ImmutableList.builder(); if (operationHandle.hasResultSet()) { TableSchema tableSchema = cliService.getResultSetMetadata(operationHandle); for (ColumnDescriptor colDesc : tableSchema.getColumnDescriptors()) { listBuilder.add(new ColumnDesc(colDesc.getName(), colDesc.getTypeName(), colDesc.getOrdinalPosition(), colDesc.getComment())); } } return listBuilder.build(); }
private List<ColumnDesc> getResultSchemaInternal(OperationHandle operationHandle) throws SQLException { ImmutableList.Builder<ColumnDesc> listBuilder = ImmutableList.builder(); if (operationHandle.hasResultSet()) { TableSchema tableSchema = cliService.getResultSetMetadata(operationHandle); for (ColumnDescriptor colDesc : tableSchema.getColumnDescriptors()) { listBuilder.add(new ColumnDesc(colDesc.getName(), colDesc.getTypeName(), colDesc.getOrdinalPosition(), colDesc.getComment())); } } return listBuilder.build(); }
@Override public void assertFunctionCall(String functionCallString, Object expectedOutputData, Object expectedOutputType) { String query = "SELECT " + functionCallString; try { // Execute the SQL statement and fetch the result OperationHandle handle = _client.executeStatement(_sessionHandle, query, null); if (handle.hasResultSet()) { RowSet rowSet = _client.fetchResults(handle); if (rowSet.numRows() > 1 || rowSet.numColumns() > 1) { throw new RuntimeException( "Expected 1 row and 1 column in query output. Received " + rowSet.numRows() + " rows and " + rowSet.numColumns() + " columns.\nQuery: \"" + query + "\""); } Object[] row = rowSet.iterator().next(); Object result = row[0]; Assert.assertEquals(result, expectedOutputData, "UDF output does not match"); // Get the output data type and convert them to TypeInfo to compare ColumnDescriptor outputColumnDescriptor = _client.getResultSetMetadata(handle).getColumnDescriptors().get(0); Assert.assertEquals(TypeInfoUtils.getTypeInfoFromTypeString(outputColumnDescriptor.getTypeName().toLowerCase()), TypeInfoUtils.getTypeInfoFromObjectInspector((ObjectInspector) expectedOutputType), "UDF output type does not match"); } else { throw new RuntimeException("Query did not return any rows. Query: \"" + query + "\""); } } catch (HiveSQLException e) { throw new RuntimeException("Error running Hive query: \"" + query + "\"", e); } } }
@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }
@Override public TGetResultSetMetadataResp GetResultSetMetadata(TGetResultSetMetadataReq req) throws TException { TGetResultSetMetadataResp resp = new TGetResultSetMetadataResp(); try { TableSchema schema = cliService.getResultSetMetadata(new OperationHandle(req.getOperationHandle())); resp.setSchema(schema.toTTableSchema()); resp.setStatus(OK_STATUS); } catch (Exception e) { LOG.warn("Error getting result set metadata: ", e); resp.setStatus(HiveSQLException.toTStatus(e)); } return resp; }