Search in sources :

Example 11 with DOUBLE

use of io.prestosql.spi.type.DoubleType.DOUBLE in project hetu-core by openlookeng.

the class TestHistogram method testManyValuesInducingRehash.

private void testManyValuesInducingRehash(InternalAggregationFunction aggregationFunction) {
    double distinctFraction = 0.1f;
    int numGroups = 50000;
    int itemCount = 30;
    Random random = new Random();
    GroupedAccumulator groupedAccumulator = createGroupedAccumulator(aggregationFunction);
    for (int j = 0; j < numGroups; j++) {
        Map<String, Long> expectedValues = new HashMap<>();
        List<String> valueList = new ArrayList<>();
        for (int i = 0; i < itemCount; i++) {
            String str = String.valueOf(i % 10);
            String item = IntStream.range(0, itemCount).mapToObj(x -> str).collect(Collectors.joining());
            boolean distinctValue = random.nextDouble() < distinctFraction;
            if (distinctValue) {
                // produce a unique value for the histogram
                item = j + "-" + item;
                valueList.add(item);
            } else {
                valueList.add(item);
            }
            expectedValues.compute(item, (k, v) -> v == null ? 1L : ++v);
        }
        Block block = createStringsBlock(valueList);
        AggregationTestInputBuilder testInputBuilder = new AggregationTestInputBuilder(new Block[] { block }, aggregationFunction);
        AggregationTestInput test1 = testInputBuilder.build();
        test1.runPagesOnAccumulatorWithAssertion(j, groupedAccumulator, new AggregationTestOutput(expectedValues));
    }
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) Arrays(java.util.Arrays) NAME(io.prestosql.operator.aggregation.histogram.Histogram.NAME) DateTimeZoneIndex.getDateTimeZone(io.prestosql.spi.util.DateTimeZoneIndex.getDateTimeZone) AggregationTestUtils.assertAggregation(io.prestosql.operator.aggregation.AggregationTestUtils.assertAggregation) StructuralTestUtil.mapBlockOf(io.prestosql.util.StructuralTestUtil.mapBlockOf) Test(org.testng.annotations.Test) Random(java.util.Random) AggregationTestInput(io.prestosql.operator.aggregation.groupby.AggregationTestInput) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) Map(java.util.Map) RowType(io.prestosql.spi.type.RowType) BOOLEAN(io.prestosql.spi.type.BooleanType.BOOLEAN) TimeZoneKey.getTimeZoneKey(io.prestosql.spi.type.TimeZoneKey.getTimeZoneKey) Ints(org.testng.internal.collections.Ints) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) BlockAssertions.createStringsBlock(io.prestosql.block.BlockAssertions.createStringsBlock) ImmutableMap(com.google.common.collect.ImmutableMap) BlockBuilder(io.prestosql.spi.block.BlockBuilder) SqlTimestampWithTimeZone(io.prestosql.spi.type.SqlTimestampWithTimeZone) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) ArrayType(io.prestosql.spi.type.ArrayType) TimeZoneKey(io.prestosql.spi.type.TimeZoneKey) Collectors(java.util.stream.Collectors) Metadata(io.prestosql.metadata.Metadata) List(java.util.List) Optional(java.util.Optional) TIMESTAMP_WITH_TIME_ZONE(io.prestosql.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE) TypeSignature(io.prestosql.spi.type.TypeSignature) GroupByAggregationTestUtils(io.prestosql.operator.aggregation.groupby.GroupByAggregationTestUtils) BlockAssertions.createStringArraysBlock(io.prestosql.block.BlockAssertions.createStringArraysBlock) IntStream(java.util.stream.IntStream) DateTimeEncoding.packDateTimeWithZone(io.prestosql.spi.type.DateTimeEncoding.packDateTimeWithZone) StandardTypes(io.prestosql.spi.type.StandardTypes) AggregationTestOutput(io.prestosql.operator.aggregation.groupby.AggregationTestOutput) HashMap(java.util.HashMap) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) ArrayList(java.util.ArrayList) MapType(io.prestosql.spi.type.MapType) OperatorAssertion.toRow(io.prestosql.operator.OperatorAssertion.toRow) VARCHAR(io.prestosql.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) Signature(io.prestosql.spi.function.Signature) Block(io.prestosql.spi.block.Block) NEW(io.prestosql.operator.aggregation.histogram.HistogramGroupImplementation.NEW) BlockAssertions.createBooleansBlock(io.prestosql.block.BlockAssertions.createBooleansBlock) DateTime(org.joda.time.DateTime) StructuralTestUtil.mapType(io.prestosql.util.StructuralTestUtil.mapType) BlockAssertions.createDoublesBlock(io.prestosql.block.BlockAssertions.createDoublesBlock) HistogramGroupImplementation(io.prestosql.operator.aggregation.histogram.HistogramGroupImplementation) BlockAssertions.createLongsBlock(io.prestosql.block.BlockAssertions.createLongsBlock) AggregationTestInputBuilder(io.prestosql.operator.aggregation.groupby.AggregationTestInputBuilder) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) AGGREGATE(io.prestosql.spi.function.FunctionKind.AGGREGATE) Assert.assertTrue(org.testng.Assert.assertTrue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Random(java.util.Random) AggregationTestOutput(io.prestosql.operator.aggregation.groupby.AggregationTestOutput) BlockAssertions.createStringsBlock(io.prestosql.block.BlockAssertions.createStringsBlock) BlockAssertions.createStringArraysBlock(io.prestosql.block.BlockAssertions.createStringArraysBlock) Block(io.prestosql.spi.block.Block) BlockAssertions.createBooleansBlock(io.prestosql.block.BlockAssertions.createBooleansBlock) BlockAssertions.createDoublesBlock(io.prestosql.block.BlockAssertions.createDoublesBlock) BlockAssertions.createLongsBlock(io.prestosql.block.BlockAssertions.createLongsBlock) AggregationTestInput(io.prestosql.operator.aggregation.groupby.AggregationTestInput) AggregationTestInputBuilder(io.prestosql.operator.aggregation.groupby.AggregationTestInputBuilder)

Example 12 with DOUBLE

use of io.prestosql.spi.type.DoubleType.DOUBLE in project hetu-core by openlookeng.

the class TestSphericalGeoFunctions method testArea.

@Test
public void testArea() throws IOException {
    // Empty polygon
    assertFunction("ST_Area(to_spherical_geography(ST_GeometryFromText('POLYGON EMPTY')))", DOUBLE, null);
    // Invalid polygon (too few vertices)
    assertInvalidFunction("ST_Area(to_spherical_geography(ST_GeometryFromText('POLYGON((90 0, 0 0))')))", "Polygon is not valid: a loop contains less then 3 vertices.");
    // Invalid data type (point)
    assertInvalidFunction("ST_Area(to_spherical_geography(ST_GeometryFromText('POINT (0 1)')))", "When applied to SphericalGeography inputs, ST_Area only supports POLYGON or MULTI_POLYGON. Input type is: POINT");
    // Invalid Polygon (duplicated point)
    assertInvalidFunction("ST_Area(to_spherical_geography(ST_GeometryFromText('POLYGON((0 0, 0 1, 1 1, 1 1, 1 0, 0 0))')))", "Polygon is not valid: it has two identical consecutive vertices");
    // A polygon around the North Pole
    assertArea("POLYGON((-135 85, -45 85, 45 85, 135 85, -135 85))", 619.00E9);
    assertArea("POLYGON((0 0, 0 1, 1 1, 1 0))", 123.64E8);
    assertArea("POLYGON((-122.150124 37.486095, -122.149201 37.486606,  -122.145725 37.486580, -122.145923 37.483961 , -122.149324 37.482480 ,  -122.150837 37.483238,  -122.150901 37.485392))", 163290.93943446054);
    double angleOfOneKm = 0.008993201943349;
    assertArea(format("POLYGON((0 0, %.15f 0, %.15f %.15f, 0 %.15f))", angleOfOneKm, angleOfOneKm, angleOfOneKm, angleOfOneKm), 1E6);
    // 1/4th of an hemisphere, ie 1/8th of the planet, should be close to 4PiR2/8 = 637.58E11
    assertArea("POLYGON((90 0, 0 0, 0 90))", 637.58E11);
    // A Polygon with a large hole
    assertArea("POLYGON((90 0, 0 0, 0 90), (89 1, 1 1, 1 89))", 348.04E10);
    Path geometryPath = Paths.get(TestSphericalGeoFunctions.class.getClassLoader().getResource("us-states.tsv").getPath());
    Map<String, String> stateGeometries = Files.lines(geometryPath).map(line -> line.split("\t")).collect(Collectors.toMap(parts -> parts[0], parts -> parts[1]));
    Path areaPath = Paths.get(TestSphericalGeoFunctions.class.getClassLoader().getResource("us-state-areas.tsv").getPath());
    Map<String, Double> stateAreas = Files.lines(areaPath).map(line -> line.split("\t")).filter(parts -> parts.length >= 2).collect(Collectors.toMap(parts -> parts[0], parts -> Double.valueOf(parts[1])));
    for (String state : stateGeometries.keySet()) {
        assertArea(stateGeometries.get(state), stateAreas.get(state));
    }
}
Also used : Path(java.nio.file.Path) Files(java.nio.file.Files) BlockBuilder(io.prestosql.spi.block.BlockBuilder) BeforeClass(org.testng.annotations.BeforeClass) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) IOException(java.io.IOException) FunctionExtractor.extractFunctions(io.prestosql.metadata.FunctionExtractor.extractFunctions) AbstractTestFunctions(io.prestosql.operator.scalar.AbstractTestFunctions) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) VARCHAR(io.prestosql.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) SPHERICAL_GEOGRAPHY(io.prestosql.plugin.geospatial.SphericalGeographyType.SPHERICAL_GEOGRAPHY) Paths(java.nio.file.Paths) Map(java.util.Map) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Type(io.prestosql.spi.type.Type) Path(java.nio.file.Path) Block(io.prestosql.spi.block.Block) Test(org.testng.annotations.Test)

Example 13 with DOUBLE

use of io.prestosql.spi.type.DoubleType.DOUBLE in project hetu-core by openlookeng.

the class MongoSession method guessFieldType.

private Optional<TypeSignature> guessFieldType(Object value) {
    if (value == null) {
        return Optional.empty();
    }
    TypeSignature typeSignature = null;
    if (value instanceof String) {
        typeSignature = createUnboundedVarcharType().getTypeSignature();
    } else if (value instanceof Integer || value instanceof Long) {
        typeSignature = BIGINT.getTypeSignature();
    } else if (value instanceof Boolean) {
        typeSignature = BOOLEAN.getTypeSignature();
    } else if (value instanceof Float || value instanceof Double) {
        typeSignature = DOUBLE.getTypeSignature();
    } else if (value instanceof Date) {
        typeSignature = TIMESTAMP.getTypeSignature();
    } else if (value instanceof ObjectId) {
        typeSignature = OBJECT_ID.getTypeSignature();
    } else if (value instanceof List) {
        List<Optional<TypeSignature>> subTypes = ((List<?>) value).stream().map(this::guessFieldType).collect(toList());
        if (subTypes.isEmpty() || subTypes.stream().anyMatch(Optional::isPresent)) {
            return Optional.empty();
        }
        Set<TypeSignature> signatures = subTypes.stream().map(Optional::get).collect(toSet());
        if (signatures.size() == 1) {
            typeSignature = new TypeSignature(StandardTypes.ARRAY, signatures.stream().map(TypeSignatureParameter::of).collect(Collectors.toList()));
        } else {
            // TODO: presto cli doesn't handle empty field name row type yet
            typeSignature = new TypeSignature(StandardTypes.ROW, IntStream.range(0, subTypes.size()).mapToObj(idx -> TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName(format("%s%d", implicitPrefix, idx + 1), false)), subTypes.get(idx).get()))).collect(toList()));
        }
    } else if (value instanceof Document) {
        List<TypeSignatureParameter> parameters = new ArrayList<>();
        for (String key : ((Document) value).keySet()) {
            Optional<TypeSignature> fieldType = guessFieldType(((Document) value).get(key));
            if (fieldType.isPresent()) {
                parameters.add(TypeSignatureParameter.of(new NamedTypeSignature(Optional.of(new RowFieldName(key, false)), fieldType.get())));
            }
        }
        if (!parameters.isEmpty()) {
            typeSignature = new TypeSignature(StandardTypes.ROW, parameters);
        }
    }
    return Optional.ofNullable(typeSignature);
}
Also used : Document(org.bson.Document) Arrays(java.util.Arrays) OBJECT_ID(io.hetu.core.plugin.mongodb.ObjectIdType.OBJECT_ID) LoadingCache(com.google.common.cache.LoadingCache) Date(java.util.Date) MongoDatabase(com.mongodb.client.MongoDatabase) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) TableNotFoundException(io.prestosql.spi.connector.TableNotFoundException) Map(java.util.Map) BOOLEAN(io.prestosql.spi.type.BooleanType.BOOLEAN) RowFieldName(io.prestosql.spi.type.RowFieldName) Type(io.prestosql.spi.type.Type) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) ENGLISH(java.util.Locale.ENGLISH) Collectors.toSet(java.util.stream.Collectors.toSet) PrestoException(io.prestosql.spi.PrestoException) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) TIMESTAMP(io.prestosql.spi.type.TimestampType.TIMESTAMP) TINYINT(io.prestosql.spi.type.TinyintType.TINYINT) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) CacheLoader(com.google.common.cache.CacheLoader) List(java.util.List) FindIterable(com.mongodb.client.FindIterable) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) Domain(io.prestosql.spi.predicate.Domain) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) TypeSignature(io.prestosql.spi.type.TypeSignature) IntStream(java.util.stream.IntStream) MongoCollection(com.mongodb.client.MongoCollection) Slice(io.airlift.slice.Slice) StandardTypes(io.prestosql.spi.type.StandardTypes) Logger(io.airlift.log.Logger) Shorts(com.google.common.primitives.Shorts) TypeSignatureParameter(io.prestosql.spi.type.TypeSignatureParameter) MINUTES(java.util.concurrent.TimeUnit.MINUTES) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) NamedTypeSignature(io.prestosql.spi.type.NamedTypeSignature) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) MongoCursor(com.mongodb.client.MongoCursor) Verify.verify(com.google.common.base.Verify.verify) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Range(io.prestosql.spi.predicate.Range) Objects.requireNonNull(java.util.Objects.requireNonNull) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) Math.toIntExact(java.lang.Math.toIntExact) IntegerType(io.prestosql.spi.type.IntegerType) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) TupleDomain(io.prestosql.spi.predicate.TupleDomain) SignedBytes(com.google.common.primitives.SignedBytes) TypeManager(io.prestosql.spi.type.TypeManager) SchemaNotFoundException(io.prestosql.spi.connector.SchemaNotFoundException) IndexOptions(com.mongodb.client.model.IndexOptions) Throwables.throwIfInstanceOf(com.google.common.base.Throwables.throwIfInstanceOf) Primitives(com.google.common.primitives.Primitives) Collectors.toList(java.util.stream.Collectors.toList) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) SMALLINT(io.prestosql.spi.type.SmallintType.SMALLINT) MongoClient(com.mongodb.MongoClient) DeleteResult(com.mongodb.client.result.DeleteResult) ObjectId(org.bson.types.ObjectId) HOURS(java.util.concurrent.TimeUnit.HOURS) VisibleForTesting(com.google.common.annotations.VisibleForTesting) VarcharType(io.prestosql.spi.type.VarcharType) Optional(java.util.Optional) ObjectId(org.bson.types.ObjectId) RowFieldName(io.prestosql.spi.type.RowFieldName) NamedTypeSignature(io.prestosql.spi.type.NamedTypeSignature) Document(org.bson.Document) Date(java.util.Date) TypeSignature(io.prestosql.spi.type.TypeSignature) NamedTypeSignature(io.prestosql.spi.type.NamedTypeSignature) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList)

Example 14 with DOUBLE

use of io.prestosql.spi.type.DoubleType.DOUBLE in project hetu-core by openlookeng.

the class HiveFileFormatBenchmark method createTpchDataSet.

private static <E extends TpchEntity> TestData createTpchDataSet(FileFormat format, TpchTable<E> tpchTable, List<TpchColumn<E>> columns) {
    List<String> columnNames = columns.stream().map(TpchColumn::getColumnName).collect(toList());
    List<Type> columnTypes = columns.stream().map(HiveFileFormatBenchmark::getColumnType).map(type -> format.supportsDate() || !DATE.equals(type) ? type : createUnboundedVarcharType()).collect(toList());
    PageBuilder pageBuilder = new PageBuilder(columnTypes);
    ImmutableList.Builder<Page> pages = ImmutableList.builder();
    long dataSize = 0;
    for (E row : tpchTable.createGenerator(10, 1, 1)) {
        pageBuilder.declarePosition();
        for (int i = 0; i < columns.size(); i++) {
            TpchColumn<E> column = columns.get(i);
            BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i);
            switch(column.getType().getBase()) {
                case IDENTIFIER:
                    BIGINT.writeLong(blockBuilder, column.getIdentifier(row));
                    break;
                case INTEGER:
                    INTEGER.writeLong(blockBuilder, column.getInteger(row));
                    break;
                case DATE:
                    if (format.supportsDate()) {
                        DATE.writeLong(blockBuilder, column.getDate(row));
                    } else {
                        createUnboundedVarcharType().writeString(blockBuilder, column.getString(row));
                    }
                    break;
                case DOUBLE:
                    DOUBLE.writeDouble(blockBuilder, column.getDouble(row));
                    break;
                case VARCHAR:
                    createUnboundedVarcharType().writeSlice(blockBuilder, Slices.utf8Slice(column.getString(row)));
                    break;
                default:
                    throw new IllegalArgumentException("Unsupported type " + column.getType());
            }
        }
        if (pageBuilder.isFull()) {
            Page page = pageBuilder.build();
            pages.add(page);
            pageBuilder.reset();
            dataSize += page.getSizeInBytes();
            if (dataSize >= MIN_DATA_SIZE) {
                break;
            }
        }
    }
    return new TestData(columnNames, columnTypes, pages.build());
}
Also used : MoreFiles.deleteRecursively(com.google.common.io.MoreFiles.deleteRecursively) RunResult(org.openjdk.jmh.results.RunResult) LINE_ITEM(io.airlift.tpch.TpchTable.LINE_ITEM) Random(java.util.Random) Warmup(org.openjdk.jmh.annotations.Warmup) ParquetFileWriterConfig(io.prestosql.plugin.hive.ParquetFileWriterConfig) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) HiveConfig(io.prestosql.plugin.hive.HiveConfig) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Files.createTempDirectory(java.nio.file.Files.createTempDirectory) Slices(io.airlift.slice.Slices) HiveTestUtils(io.prestosql.plugin.hive.HiveTestUtils) TearDown(org.openjdk.jmh.annotations.TearDown) Type(io.prestosql.spi.type.Type) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Setup(org.openjdk.jmh.annotations.Setup) BlockBuilder(io.prestosql.spi.block.BlockBuilder) Param(org.openjdk.jmh.annotations.Param) ArrayType(io.prestosql.spi.type.ArrayType) Collection(java.util.Collection) UUID(java.util.UUID) PageBuilder(io.prestosql.spi.PageBuilder) OrcFileWriterConfig(io.prestosql.plugin.hive.OrcFileWriterConfig) String.format(java.lang.String.format) TpchTable(io.airlift.tpch.TpchTable) UncheckedIOException(java.io.UncheckedIOException) TpchEntity(io.airlift.tpch.TpchEntity) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) DataSize(io.airlift.units.DataSize) List(java.util.List) ConnectorPageSource(io.prestosql.spi.connector.ConnectorPageSource) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) HiveCompressionCodec(io.prestosql.plugin.hive.HiveCompressionCodec) Options(org.openjdk.jmh.runner.options.Options) TpchColumn(io.airlift.tpch.TpchColumn) Measurement(org.openjdk.jmh.annotations.Measurement) HiveSessionProperties(io.prestosql.plugin.hive.HiveSessionProperties) ORDERS(io.airlift.tpch.TpchTable.ORDERS) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) Scope(org.openjdk.jmh.annotations.Scope) INTEGER(io.prestosql.spi.type.IntegerType.INTEGER) OrderColumn(io.airlift.tpch.OrderColumn) ArrayList(java.util.ArrayList) HdfsEnvironment(io.prestosql.plugin.hive.HdfsEnvironment) Statistics(org.openjdk.jmh.util.Statistics) AuxCounters(org.openjdk.jmh.annotations.AuxCounters) ALLOW_INSECURE(com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE) ImmutableList(com.google.common.collect.ImmutableList) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) DATE(io.prestosql.spi.type.DateType.DATE) Runner(org.openjdk.jmh.runner.Runner) HadoopNative(io.prestosql.hadoop.HadoopNative) Page(io.prestosql.spi.Page) IOException(java.io.IOException) State(org.openjdk.jmh.annotations.State) Benchmark(org.openjdk.jmh.annotations.Benchmark) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) Fork(org.openjdk.jmh.annotations.Fork) TestingConnectorSession(io.prestosql.testing.TestingConnectorSession) IntArrays(it.unimi.dsi.fastutil.ints.IntArrays) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) ALLOW_INSECURE(com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) DATE(io.prestosql.spi.type.DateType.DATE) ImmutableList(com.google.common.collect.ImmutableList) Page(io.prestosql.spi.Page) PageBuilder(io.prestosql.spi.PageBuilder) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 15 with DOUBLE

use of io.prestosql.spi.type.DoubleType.DOUBLE in project hetu-core by openlookeng.

the class TestOutputNodeStats method testStatsForOutputNode.

@Test
public void testStatsForOutputNode() {
    PlanNodeStatsEstimate stats = PlanNodeStatsEstimate.builder().setOutputRowCount(100).addSymbolStatistics(new Symbol("a"), SymbolStatsEstimate.builder().setNullsFraction(0.3).setLowValue(1).setHighValue(30).setDistinctValuesCount(20).build()).addSymbolStatistics(new Symbol("b"), SymbolStatsEstimate.builder().setNullsFraction(0.6).setLowValue(13.5).setHighValue(POSITIVE_INFINITY).setDistinctValuesCount(40).build()).build();
    tester().assertStatsFor(pb -> pb.output(outputBuilder -> {
        Symbol a = pb.symbol("a", BIGINT);
        Symbol b = pb.symbol("b", DOUBLE);
        outputBuilder.source(pb.values(a, b)).column(a, "a1").column(a, "a2").column(b, "b");
    })).withSourceStats(stats).check(outputStats -> outputStats.equalTo(stats));
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) POSITIVE_INFINITY(java.lang.Double.POSITIVE_INFINITY) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) Test(org.testng.annotations.Test) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Symbol(io.prestosql.spi.plan.Symbol) Test(org.testng.annotations.Test)

Aggregations

DOUBLE (io.prestosql.spi.type.DoubleType.DOUBLE)22 BIGINT (io.prestosql.spi.type.BigintType.BIGINT)19 Optional (java.util.Optional)17 ImmutableList (com.google.common.collect.ImmutableList)16 List (java.util.List)16 ImmutableMap (com.google.common.collect.ImmutableMap)15 Type (io.prestosql.spi.type.Type)15 INTEGER (io.prestosql.spi.type.IntegerType.INTEGER)13 Test (org.testng.annotations.Test)12 Map (java.util.Map)11 SMALLINT (io.prestosql.spi.type.SmallintType.SMALLINT)10 ArrayList (java.util.ArrayList)10 Slice (io.airlift.slice.Slice)9 TINYINT (io.prestosql.spi.type.TinyintType.TINYINT)9 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)8 DATE (io.prestosql.spi.type.DateType.DATE)8 DecimalType (io.prestosql.spi.type.DecimalType)8 REAL (io.prestosql.spi.type.RealType.REAL)8 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)7 String.format (java.lang.String.format)7