Search in sources :

Example 6 with Type

use of com.facebook.presto.spi.type.Type in project presto by prestodb.

the class TestField method testInt.

@Test
public void testInt() throws Exception {
    Type type = INTEGER;
    Integer expected = 12345678;
    Field f1 = new Field(expected, type);
    assertEquals(f1.getInt(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);
    assertEquals(f1.toString(), "12345678");
    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) Test(org.testng.annotations.Test)

Example 7 with Type

use of com.facebook.presto.spi.type.Type in project presto by prestodb.

the class TestField method testVarbinary.

@Test
public void testVarbinary() throws Exception {
    Type type = VARBINARY;
    byte[] expected = "O'Leary".getBytes(UTF_8);
    Field f1 = new Field(expected, type);
    assertEquals(f1.getVarbinary(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);
    assertEquals(f1.toString(), "CAST('O''Leary' AS VARBINARY)");
    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) Test(org.testng.annotations.Test)

Example 8 with Type

use of com.facebook.presto.spi.type.Type in project presto by prestodb.

the class TestField method testDate.

@Test
public void testDate() throws Exception {
    Type type = DATE;
    Date expected = new Date(new GregorianCalendar(1999, 0, 1).getTime().getTime());
    Field f1 = new Field(expected, type);
    assertEquals(f1.getDate(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);
    assertEquals(f1.toString(), "DATE '1999-01-01'");
    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) GregorianCalendar(java.util.GregorianCalendar) Date(java.sql.Date) Test(org.testng.annotations.Test)

Example 9 with Type

use of com.facebook.presto.spi.type.Type in project presto by prestodb.

the class TestField method testSmallInt.

@Test
public void testSmallInt() throws Exception {
    Type type = SMALLINT;
    Short expected = 12345;
    Field f1 = new Field(expected, type);
    assertEquals(f1.getShort(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);
    assertEquals(f1.toString(), "12345");
    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) Test(org.testng.annotations.Test)

Example 10 with Type

use of com.facebook.presto.spi.type.Type in project presto by prestodb.

the class AbstractTestAccumuloRowSerializer method testVarbinary.

@Test
public void testVarbinary() throws Exception {
    AccumuloRowSerializer serializer = serializerClass.getConstructor().newInstance();
    Type type = VARBINARY;
    byte[] expected = b(UUID.randomUUID().toString());
    byte[] data = serializer.encode(type, expected);
    byte[] actual = serializer.decode(type, data);
    assertEquals(actual, expected);
    deserializeData(serializer, data);
    actual = serializer.getVarbinary(COLUMN_NAME);
    assertEquals(actual, expected);
}
Also used : ArrayType(com.facebook.presto.type.ArrayType) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) Test(org.testng.annotations.Test)

Aggregations

Type (com.facebook.presto.spi.type.Type)392 Test (org.testng.annotations.Test)103 Block (com.facebook.presto.spi.block.Block)83 ImmutableList (com.google.common.collect.ImmutableList)79 ArrayType (com.facebook.presto.type.ArrayType)78 MapType (com.facebook.presto.type.MapType)72 Page (com.facebook.presto.spi.Page)68 PrestoException (com.facebook.presto.spi.PrestoException)51 List (java.util.List)50 VarcharType (com.facebook.presto.spi.type.VarcharType)48 DecimalType (com.facebook.presto.spi.type.DecimalType)44 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)40 MaterializedResult (com.facebook.presto.testing.MaterializedResult)40 ArrayList (java.util.ArrayList)40 MethodHandle (java.lang.invoke.MethodHandle)39 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)37 ImmutableMap (com.google.common.collect.ImmutableMap)36 Map (java.util.Map)36 Slice (io.airlift.slice.Slice)35 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)30