Search in sources :

Example 1 with TypeSignatureProvider

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

the class TestMinMaxByAggregation method testMinLongArrayLongArray.

@Test
public void testMinLongArrayLongArray() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(new ArrayType(BIGINT), new ArrayType(BIGINT));
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, asList(1L, 2L), createArrayBigintBlock(asList(asList(3L, 3L), null, asList(1L, 2L))), 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 2 with TypeSignatureProvider

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

the class TestMinMaxByAggregation method testMinDoubleLongArray.

@Test
public void testMinDoubleLongArray() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(new ArrayType(BIGINT), DOUBLE);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, asList(3L, 4L), createArrayBigintBlock(asList(asList(3L, 4L), null, asList(2L, 2L))), createDoublesBlock(1.0, 2.0, 3.0));
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, null, createArrayBigintBlock(asList(null, null, asList(2L, 2L))), createDoublesBlock(0.0, 1.0, 2.0));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) Test(org.testng.annotations.Test)

Example 3 with TypeSignatureProvider

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

the class TestMinMaxByAggregation method testMaxLongLongArray.

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

Example 4 with TypeSignatureProvider

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

the class TestMinMaxByAggregation method testMaxUnknownLongArray.

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

Example 5 with TypeSignatureProvider

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

the class TestMinMaxByNAggregation method testMinArrayVarchar.

@Test
public void testMinArrayVarchar() {
    List<TypeSignatureProvider> parameterTypes = fromTypes(VARCHAR, new ArrayType(BIGINT), BIGINT);
    assertAggregation(FUNCTION_RESOLUTION, QualifiedName.of("min_by"), parameterTypes, ImmutableList.of("b", "x", "z"), 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)

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