@Test public void testShowColumnStats() { // FIXME Add tests for more complex scenario with more stats MaterializedResult result = computeActual("SHOW STATS FOR nation"); MaterializedResult expectedStatistics = resultBuilder(getSession(), VARCHAR, DOUBLE, DOUBLE, DOUBLE, DOUBLE, VARCHAR, VARCHAR) .row("nationkey", null, 25.0, 0.0, null, "0", "24") .row("name", 177.0, 25.0, 0.0, null, null, null) .row("regionkey", null, 5.0, 0.0, null, "0", "4") .row("comment", 1857.0, 25.0, 0.0, null, null, null) .row(null, null, null, null, 25.0, null, null) .build(); assertEquals(result, expectedStatistics); }
@Test public void testIOExplain() { String query = "SELECT * FROM orders"; MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) " + query); TableColumnInfo input = new TableColumnInfo( new CatalogSchemaTableName("local", "sf0.01", "orders"), ImmutableSet.of( new ColumnConstraint( "orderstatus", createVarcharType(1).getTypeSignature(), new FormattedDomain( false, ImmutableSet.of( new FormattedRange( new FormattedMarker(Optional.of("F"), EXACTLY), new FormattedMarker(Optional.of("F"), EXACTLY)), new FormattedRange( new FormattedMarker(Optional.of("O"), EXACTLY), new FormattedMarker(Optional.of("O"), EXACTLY)), new FormattedRange( new FormattedMarker(Optional.of("P"), EXACTLY), new FormattedMarker(Optional.of("P"), EXACTLY))))))); assertEquals( jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IOPlan(ImmutableSet.of(input), Optional.empty())); } }
@Test public void testShowColumnStats() { // FIXME Add tests for more complex scenario with more stats MaterializedResult result = computeActual("SHOW STATS FOR nation"); MaterializedResult expectedStatistics = resultBuilder(getSession(), VARCHAR, DOUBLE, DOUBLE, DOUBLE, DOUBLE, VARCHAR, VARCHAR) .row("nationkey", null, 25.0, 0.0, null, "0", "24") .row("name", 177.0, 25.0, 0.0, null, null, null) .row("regionkey", null, 5.0, 0.0, null, "0", "4") .row("comment", 1857.0, 25.0, 0.0, null, null, null) .row(null, null, null, null, 25.0, null, null) .build(); assertEquals(result, expectedStatistics); }
@Test public void testIOExplain() { String query = "SELECT * FROM orders"; MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) " + query); TableColumnInfo input = new TableColumnInfo( new CatalogSchemaTableName("local", "sf0.01", "orders"), ImmutableSet.of( new ColumnConstraint( "orderstatus", createVarcharType(1).getTypeSignature(), new FormattedDomain( false, ImmutableSet.of( new FormattedRange( new FormattedMarker(Optional.of("F"), EXACTLY), new FormattedMarker(Optional.of("F"), EXACTLY)), new FormattedRange( new FormattedMarker(Optional.of("O"), EXACTLY), new FormattedMarker(Optional.of("O"), EXACTLY)), new FormattedRange( new FormattedMarker(Optional.of("P"), EXACTLY), new FormattedMarker(Optional.of("P"), EXACTLY))))))); assertEquals( jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IOPlan(ImmutableSet.of(input), Optional.empty())); } }