Search in sources :

Example 6 with TypeSignatureProvider

use of io.trino.sql.analyzer.TypeSignatureProvider in project trino by trinodb.

the class TestMinMaxByNAggregation method testMinVarcharArray.

@Test
public void testMinVarcharArray() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(new ArrayType(BIGINT), VARCHAR, BIGINT);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, ImmutableList.of(ImmutableList.of(2L, 3L), ImmutableList.of(4L, 5L)), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(2L, 3L), ImmutableList.of(3L, 4L), ImmutableList.of(4L, 5L))), createStringsBlock("z", "a", "x", "b"), createRLEBlock(2L, 4));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Example 7 with TypeSignatureProvider

use of io.trino.sql.analyzer.TypeSignatureProvider in project trino by trinodb.

the class TestMinMaxByNAggregation method testMaxVarcharArray.

@Test
public void testMaxVarcharArray() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(new ArrayType(BIGINT), VARCHAR, BIGINT);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("max_by"), parameterTypes, ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(3L, 4L)), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(2L, 3L), ImmutableList.of(3L, 4L), ImmutableList.of(4L, 5L))), createStringsBlock("z", "a", "x", "b"), createRLEBlock(2L, 4));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Example 8 with TypeSignatureProvider

use of io.trino.sql.analyzer.TypeSignatureProvider in project trino by trinodb.

the class TestMinMaxByNAggregation method testMaxArrayVarchar.

@Test
public void testMaxArrayVarchar() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(VARCHAR, new ArrayType(BIGINT), BIGINT);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("max_by"), parameterTypes, ImmutableList.of("a", "z", "x"), createStringsBlock("z", "a", "x", "b"), createArrayBigintBlock(ImmutableList.of(ImmutableList.of(1L, 2L), ImmutableList.of(2L, 3L), ImmutableList.of(0L, 3L), ImmutableList.of(0L, 2L))), createRLEBlock(3L, 4));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Example 9 with TypeSignatureProvider

use of io.trino.sql.analyzer.TypeSignatureProvider in project trino by trinodb.

the class TestMinMaxByAggregation method testMinLongArraySlice.

@Test
public void testMinLongArraySlice() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(VARCHAR, new ArrayType(BIGINT));
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, "c", createStringsBlock("a", "b", "c"), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Example 10 with TypeSignatureProvider

use of io.trino.sql.analyzer.TypeSignatureProvider in project trino by trinodb.

the class TestMinMaxByAggregation method testMaxBooleanLongArray.

@Test
public void testMaxBooleanLongArray() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(new ArrayType(BIGINT), BOOLEAN);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("max_by"), parameterTypes, asList(2L, 2L), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createBooleansBlock(false, false, true));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Aggregations

TypeSignatureProvider (io.trino.sql.analyzer.TypeSignatureProvider)22 ArrayType (io.trino.spi.type.ArrayType)21 Test (org.testng.annotations.Test)21 ImmutableList (com.google.common.collect.ImmutableList)2 RowType (io.trino.spi.type.RowType)2 Type (io.trino.spi.type.Type)2 TypeSignature (io.trino.spi.type.TypeSignature)2 TypeSignatureParameter (io.trino.spi.type.TypeSignatureParameter)2 FunctionType (io.trino.type.FunctionType)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 TEST_SESSION (io.trino.SessionTestUtils.TEST_SESSION)1 Signature.castableFromTypeParameter (io.trino.metadata.Signature.castableFromTypeParameter)1 Signature.castableToTypeParameter (io.trino.metadata.Signature.castableToTypeParameter)1 Signature.comparableTypeParameter (io.trino.metadata.Signature.comparableTypeParameter)1 Signature.orderableTypeParameter (io.trino.metadata.Signature.orderableTypeParameter)1 Signature.typeVariable (io.trino.metadata.Signature.typeVariable)1 Signature.withVariadicBound (io.trino.metadata.Signature.withVariadicBound)1 BIGINT (io.trino.spi.type.BigintType.BIGINT)1 BOOLEAN (io.trino.spi.type.BooleanType.BOOLEAN)1