mirror of https://github.com/apache/iotdb
add aggregation name in result show
This commit is contained in:
parent
87f3c8fe6f
commit
66b1416144
1
pom.xml
1
pom.xml
|
@ -92,7 +92,6 @@
|
|||
<testIncludes>
|
||||
<testInclude>**/*.java</testInclude>
|
||||
</testIncludes>
|
||||
<outputDirectory>${project.build.directory}/it-classes</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -18,7 +18,6 @@ import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp;
|
|||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle;
|
||||
|
|
|
@ -34,4 +34,7 @@ public abstract class PhysicalPlan {
|
|||
return operatorType;
|
||||
}
|
||||
|
||||
public List<String> getAggregations(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.*;
|
||||
import org.apache.thrift.TException;
|
||||
import org.apache.thrift.server.ServerContext;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
@ -27,40 +28,12 @@ import cn.edu.thu.tsfiledb.exception.PathErrorException;
|
|||
import cn.edu.thu.tsfiledb.metadata.MManager;
|
||||
import cn.edu.thu.tsfiledb.metadata.Metadata;
|
||||
import cn.edu.thu.tsfiledb.qp.QueryProcessor;
|
||||
import cn.edu.thu.tsfiledb.qp.constant.SQLConstant;
|
||||
import cn.edu.thu.tsfiledb.qp.exception.IllegalASTFormatException;
|
||||
import cn.edu.thu.tsfiledb.qp.exception.QueryProcessorException;
|
||||
import cn.edu.thu.tsfiledb.qp.executor.OverflowQPExecutor;
|
||||
import cn.edu.thu.tsfiledb.qp.logical.Operator.OperatorType;
|
||||
import cn.edu.thu.tsfiledb.qp.physical.PhysicalPlan;
|
||||
import cn.edu.thu.tsfiledb.query.management.ReadLockManager;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSGetTimeZoneResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSHandleIdentifier;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSSetTimeZoneReq;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSSetTimeZoneResp;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_Status;
|
||||
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode;
|
||||
import cn.edu.thu.tsfiledb.sys.writelog.WriteLogManager;
|
||||
import cn.edu.tsinghua.tsfile.common.exception.ProcessorException;
|
||||
import cn.edu.tsinghua.tsfile.timeseries.read.qp.Path;
|
||||
|
@ -364,13 +337,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
|
|||
List<String> columns = new ArrayList<>();
|
||||
// Restore column header of aggregate to func(column_name), only
|
||||
// support single aggregate function for now
|
||||
String aggregateFuncName = null;
|
||||
try {
|
||||
aggregateFuncName = (String) processor.getExecutor().getParameter(SQLConstant.IS_AGGREGATION);
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
if (aggregateFuncName != null) {
|
||||
columns.add(aggregateFuncName + "(" + paths.get(0).getFullPath() + ")");
|
||||
List<String> aggregations = plan.getAggregations();
|
||||
|
||||
if (aggregations != null && !aggregations.isEmpty()) {
|
||||
for(int i = 0; i < aggregations.size(); i++) {
|
||||
columns.add(aggregations.get(i) + "(" + paths.get(i).getFullPath() + ")");
|
||||
}
|
||||
} else {
|
||||
for (Path p : paths) {
|
||||
columns.add(p.getFullPath());
|
||||
|
@ -383,7 +355,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
|
|||
operationHandle = new TSOperationHandle(operationId, true);
|
||||
resp.setOperationHandle(operationHandle);
|
||||
recordANewQuery(statement, plan);
|
||||
resp.setOperationType(aggregateFuncName);
|
||||
resp.setOperationType(aggregations);
|
||||
return resp;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("{}: Internal server error: {}",TsFileDBConstant.GLOBAL_DB_NAME, e.getMessage());
|
||||
|
|
|
@ -491,11 +491,11 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
return _Fields.findByThriftId(fieldId);
|
||||
}
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot) throws TException {
|
||||
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot) throws TException {
|
||||
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
|
||||
}
|
||||
|
||||
|
@ -545,10 +545,10 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public void validate() throws org.apache.thrift.TException {
|
||||
public void validate() throws TException {
|
||||
// check for required fields
|
||||
if (status == null) {
|
||||
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
|
||||
throw new TProtocolException("Required field 'status' was not present! Struct: " + toString());
|
||||
}
|
||||
// check for sub-struct validity
|
||||
if (status != null) {
|
||||
|
@ -562,7 +562,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
|
||||
try {
|
||||
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
} catch (TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
|
||||
try {
|
||||
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
|
||||
} catch (org.apache.thrift.TException te) {
|
||||
} catch (TException te) {
|
||||
throw new java.io.IOException(te);
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
|
||||
private static class TSExecuteStatementRespStandardScheme extends StandardScheme<TSExecuteStatementResp> {
|
||||
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
|
||||
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementResp struct) throws TException {
|
||||
org.apache.thrift.protocol.TField schemeField;
|
||||
iprot.readStructBegin();
|
||||
while (true)
|
||||
|
@ -658,7 +658,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
struct.validate();
|
||||
}
|
||||
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
|
||||
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementResp struct) throws TException {
|
||||
struct.validate();
|
||||
|
||||
oprot.writeStructBegin(STRUCT_DESC);
|
||||
|
@ -717,7 +717,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
private static class TSExecuteStatementRespTupleScheme extends TupleScheme<TSExecuteStatementResp> {
|
||||
|
||||
@Override
|
||||
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
|
||||
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws TException {
|
||||
TTupleProtocol oprot = (TTupleProtocol) prot;
|
||||
struct.status.write(oprot);
|
||||
BitSet optionals = new BitSet();
|
||||
|
@ -755,7 +755,7 @@ public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecute
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
|
||||
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws TException {
|
||||
TTupleProtocol iprot = (TTupleProtocol) prot;
|
||||
struct.status = new TS_Status();
|
||||
struct.status.read(iprot);
|
||||
|
|
Loading…
Reference in New Issue