Skip to content

Commit

Permalink
Remove usage of parseTypeSignature from operator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed Oct 14, 2019
1 parent cab9af6 commit e370c33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
import static io.prestosql.spi.type.BigintType.BIGINT;
import static io.prestosql.spi.type.BooleanType.BOOLEAN;
import static io.prestosql.spi.type.DoubleType.DOUBLE;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.VarcharType.createVarcharType;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -384,7 +386,7 @@ public void testComplexParametricScalarParse()
ImmutableList.of(),
ImmutableList.of(),
BOOLEAN.getTypeSignature(),
ImmutableList.of(parseTypeSignature("array(varchar(17))")),
ImmutableList.of(arrayType(createVarcharType(17).getTypeSignature())),
false);

List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ComplexParametricScalarFunction.class);
Expand Down Expand Up @@ -482,7 +484,7 @@ public void testConstructorInjectionScalarParse()
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
BIGINT.getTypeSignature(),
ImmutableList.of(parseTypeSignature("array(T)")),
ImmutableList.of(arrayType(new TypeSignature("T"))),
false);

List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ConstructorInjectionScalarFunction.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import static io.prestosql.spi.type.BigintType.BIGINT;
import static io.prestosql.spi.type.BooleanType.BOOLEAN;
import static io.prestosql.spi.type.DoubleType.DOUBLE;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.arrayType;
import static io.prestosql.spi.type.VarcharType.VARCHAR;
import static io.prestosql.testing.MaterializedResult.resultBuilder;
import static io.prestosql.testing.TestingTaskContext.createTaskContext;
Expand Down Expand Up @@ -271,7 +271,7 @@ public void testHashAggregationMemoryReservation(boolean hashEnabled, boolean sp
{
Metadata metadata = createTestMetadataManager();
InternalAggregationFunction arrayAggColumn = metadata.getAggregateFunctionImplementation(
new Signature("array_agg", AGGREGATE, parseTypeSignature("array(bigint)"), BIGINT.getTypeSignature()));
new Signature("array_agg", AGGREGATE, arrayType(BIGINT.getTypeSignature()), BIGINT.getTypeSignature()));

List<Integer> hashChannels = Ints.asList(1);
RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, hashChannels, BIGINT, BIGINT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import static io.prestosql.operator.OperatorAssertion.assertOperatorEquals;
import static io.prestosql.spi.type.BigintType.BIGINT;
import static io.prestosql.spi.type.DoubleType.DOUBLE;
import static io.prestosql.spi.type.TypeSignature.parseTypeSignature;
import static io.prestosql.spi.type.TypeSignature.mapType;
import static io.prestosql.spi.type.VarcharType.VARCHAR;
import static io.prestosql.testing.MaterializedResult.resultBuilder;
import static io.prestosql.testing.TestingTaskContext.createTaskContext;
Expand Down Expand Up @@ -80,8 +80,8 @@ public void tearDown()
public void testUnnest()
{
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
Type arrayType = new ArrayType(BIGINT);
Type mapType = metadata.getType(mapType(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()));

List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType)
.row(1L, arrayBlockOf(BIGINT, 2, 3), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(4, 5)))
Expand Down Expand Up @@ -109,8 +109,8 @@ public void testUnnest()
public void testUnnestWithArray()
{
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(array(bigint))"));
Type mapType = metadata.getType(parseTypeSignature("map(array(bigint),array(bigint))"));
Type arrayType = new ArrayType(new ArrayType(BIGINT));
Type mapType = metadata.getType(mapType(new ArrayType(BIGINT).getTypeSignature(), new ArrayType(BIGINT).getTypeSignature()));

List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType)
.row(
Expand Down Expand Up @@ -144,8 +144,8 @@ public void testUnnestWithArray()
public void testUnnestWithOrdinality()
{
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
Type arrayType = new ArrayType(BIGINT);
Type mapType = metadata.getType(mapType(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()));

List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType)
.row(1L, arrayBlockOf(BIGINT, 2, 3), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(4, 5)))
Expand Down Expand Up @@ -173,8 +173,8 @@ public void testUnnestWithOrdinality()
public void testUnnestNonNumericDoubles()
{
Metadata metadata = createTestMetadataManager();
Type arrayType = metadata.getType(parseTypeSignature("array(double)"));
Type mapType = metadata.getType(parseTypeSignature("map(bigint,double)"));
Type arrayType = new ArrayType(DOUBLE);
Type mapType = metadata.getType(mapType(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()));

List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType)
.row(1L, arrayBlockOf(DOUBLE, NEGATIVE_INFINITY, POSITIVE_INFINITY, NaN),
Expand All @@ -196,9 +196,8 @@ public void testUnnestNonNumericDoubles()
@Test
public void testUnnestWithArrayOfRows()
{
Metadata metadata = createTestMetadataManager();
Type arrayOfRowType = metadata.getType(parseTypeSignature("array(row(bigint, double, varchar))"));
Type elementType = RowType.anonymous(ImmutableList.of(BIGINT, DOUBLE, VARCHAR));
Type arrayOfRowType = new ArrayType(elementType);

List<Page> input = rowPagesBuilder(BIGINT, arrayOfRowType)
.row(1, arrayBlockOf(elementType, ImmutableList.of(2, 4.2, "abc"), ImmutableList.of(3, 6.6, "def")))
Expand Down Expand Up @@ -227,10 +226,10 @@ public void testUnnestWithArrayOfRows()
public void testOuterUnnest()
{
Metadata metadata = createTestMetadataManager();
Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
Type arrayOfRowType = metadata.getType(parseTypeSignature("array(row(bigint, double, varchar))"));
Type mapType = metadata.getType(mapType(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()));
Type arrayType = new ArrayType(BIGINT);
Type elementType = RowType.anonymous(ImmutableList.of(BIGINT, DOUBLE, VARCHAR));
Type arrayOfRowType = new ArrayType(elementType);

List<Page> input = rowPagesBuilder(BIGINT, mapType, arrayType, arrayOfRowType)
.row(
Expand Down Expand Up @@ -260,10 +259,10 @@ public void testOuterUnnest()
public void testOuterUnnestWithOrdinality()
{
Metadata metadata = createTestMetadataManager();
Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
Type arrayOfRowType = metadata.getType(parseTypeSignature("array(row(bigint, double, varchar))"));
Type mapType = metadata.getType(mapType(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()));
Type arrayType = new ArrayType(BIGINT);
Type elementType = RowType.anonymous(ImmutableList.of(BIGINT, DOUBLE, VARCHAR));
Type arrayOfRowType = new ArrayType(elementType);

List<Page> input = rowPagesBuilder(BIGINT, mapType, arrayType, arrayOfRowType)
.row(
Expand Down

0 comments on commit e370c33

Please sign in to comment.