use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class TestAnalyzer method testUnionDistinctPerformanceWarning.
@Test
public void testUnionDistinctPerformanceWarning() {
WarningCollector warningCollector = analyzeWithWarnings("SELECT a,b,c,d FROM t8 UNION DISTINCT SELECT a,b,c,d FROM t9");
List<PrestoWarning> warnings = warningCollector.getWarnings();
assertEquals(warnings.size(), 1);
// Ensure warning is the performance warning we expect
PrestoWarning warning = warnings.get(0);
assertEquals(warning.getWarningCode(), PERFORMANCE_WARNING.toWarningCode());
assertTrue(warning.getMessage().startsWith("UNION DISTINCT"));
}
use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class TestAnalyzer method testCountDistinctPerformanceWarning.
@Test
public void testCountDistinctPerformanceWarning() {
WarningCollector warningCollector = analyzeWithWarnings("SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b");
List<PrestoWarning> warnings = warningCollector.getWarnings();
assertEquals(warnings.size(), 1);
// Ensure warning is the performance warning we expect
PrestoWarning warning = warnings.get(0);
assertEquals(warning.getWarningCode(), PERFORMANCE_WARNING.toWarningCode());
assertTrue(warning.getMessage().contains("COUNT(DISTINCT xxx)"));
}
use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class WarnOnScanWithoutPartitionPredicate method validate.
@Override
public void validate(PlanNode plan, Session session, Metadata metadata, SqlParser sqlParser, TypeProvider types, WarningCollector warningCollector) {
for (TableScanNode scan : searchFrom(plan).where(TableScanNode.class::isInstance).<TableScanNode>findAll()) {
TableHandle tableHandle = scan.getTable();
TableLayoutFilterCoverage partitioningFilterCoverage = metadata.getTableLayoutFilterCoverage(session, tableHandle, warnOnNoTableLayoutFilter);
if (partitioningFilterCoverage == NOT_COVERED) {
String warningMessage = String.format("No partition filter for scan of table %s", scan.getTable().getConnectorHandle());
warningCollector.add(new PrestoWarning(PERFORMANCE_WARNING, warningMessage));
}
}
}
use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class KeyBasedSampler method optimize.
@Override
public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, PlanVariableAllocator variableAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector) {
if (isKeyBasedSamplingEnabled(session)) {
List<String> sampledFields = new ArrayList<>(2);
PlanNode rewritten = SimplePlanRewriter.rewriteWith(new Rewriter(session, metadata.getFunctionAndTypeManager(), idAllocator, sampledFields), plan, null);
if (!sampledFields.isEmpty()) {
warningCollector.add(new PrestoWarning(SAMPLED_FIELDS, String.format("Sampled the following columns/derived columns at %s percent:\n\t%s", getKeyBasedSamplingPercentage(session) * 100., String.join("\n\t", sampledFields))));
} else {
warningCollector.add(new PrestoWarning(SEMANTIC_WARNING, "Sampling could not be performed due to the query structure"));
}
return rewritten;
}
return plan;
}
use of com.facebook.presto.spi.PrestoWarning in project presto by prestodb.
the class TestPlannerWarnings method createTestWarnings.
public static List<PrestoWarning> createTestWarnings(int numberOfWarnings) {
checkArgument(numberOfWarnings > 0, "numberOfWarnings must be > 0");
ImmutableList.Builder<PrestoWarning> builder = ImmutableList.builder();
range(1, numberOfWarnings).mapToObj(code -> new PrestoWarning(new WarningCode(code, "testWarning"), "Test warning " + code)).forEach(builder::add);
return builder.build();
}
Aggregations