Search in sources :

Example 16 with DataType

use of com.pingcap.tikv.types.DataType in project tispark by pingcap.

the class SchemaInferTest method selectAggWithGroupBySchemaInferTest.

@Test
public void selectAggWithGroupBySchemaInferTest() {
    // select sum(number) from t1 group by name;
    List<TiDAGRequest> dagRequests = makeSelectDAGReq(simpleGroupBy, complexGroupBy);
    for (TiDAGRequest req : dagRequests) {
        List<DataType> dataTypes = SchemaInfer.create(req).getTypes();
        assertEquals(2, dataTypes.size());
        assertEquals(IntegerType.BIGINT.getClass(), dataTypes.get(0).getClass());
        assertEquals(IntegerType.BIGINT.getClass(), dataTypes.get(1).getClass());
    }
}
Also used : DataType(com.pingcap.tikv.types.DataType) TiDAGRequest(com.pingcap.tikv.meta.TiDAGRequest) Test(org.junit.Test)

Example 17 with DataType

use of com.pingcap.tikv.types.DataType in project tispark by pingcap.

the class SchemaInferTest method selectAggSchemaInferTest.

@Test
public void selectAggSchemaInferTest() {
    // select sum(number) from t1;
    TiDAGRequest tiDAGRequest = new TiDAGRequest(TiDAGRequest.PushDownType.NORMAL);
    tiDAGRequest.addRequiredColumn(number);
    tiDAGRequest.addAggregate(sum);
    tiDAGRequest.setTableInfo(table);
    tiDAGRequest.setStartTs(ts);
    List<DataType> dataTypes = SchemaInfer.create(tiDAGRequest).getTypes();
    assertEquals(1, dataTypes.size());
    assertEquals(IntegerType.INT.getClass(), dataTypes.get(0).getClass());
}
Also used : DataType(com.pingcap.tikv.types.DataType) TiDAGRequest(com.pingcap.tikv.meta.TiDAGRequest) Test(org.junit.Test)

Aggregations

DataType (com.pingcap.tikv.types.DataType)17 TiDAGRequest (com.pingcap.tikv.meta.TiDAGRequest)5 Test (org.junit.Test)5 InternalTypeHolder (com.pingcap.tikv.meta.TiColumnInfo.InternalTypeHolder)3 ByteString (com.google.protobuf.ByteString)2 Expr (com.pingcap.tidb.tipb.Expr)2 CodecDataInput (com.pingcap.tikv.codec.CodecDataInput)2 FuncCallExpr (com.pingcap.tikv.expression.FuncCallExpr)2 TiIndexColumn (com.pingcap.tikv.meta.TiIndexColumn)2 Row (com.pingcap.tikv.row.Row)2 ArrayList (java.util.ArrayList)2 ScalarFuncSig (com.pingcap.tidb.tipb.ScalarFuncSig)1 CodecDataOutput (com.pingcap.tikv.codec.CodecDataOutput)1 BatchedTiChunkColumnVector (com.pingcap.tikv.columnar.BatchedTiChunkColumnVector)1 TiChunk (com.pingcap.tikv.columnar.TiChunk)1 TiChunkColumnVector (com.pingcap.tikv.columnar.TiChunkColumnVector)1 TiRowColumnVector (com.pingcap.tikv.columnar.TiRowColumnVector)1 CHType (com.pingcap.tikv.columnar.datatypes.CHType)1 CodecException (com.pingcap.tikv.exception.CodecException)1 TiExpressionException (com.pingcap.tikv.exception.TiExpressionException)1