use of io.trino.sql.planner.OptimizerConfig in project trino by trinodb.
the class TestOptimizerConfig method testExplicitPropertyMappings.
@Test
public void testExplicitPropertyMappings() {
Map<String, String> properties = ImmutableMap.<String, String>builder().put("cpu-cost-weight", "0.4").put("memory-cost-weight", "0.3").put("network-cost-weight", "0.2").put("enable-stats-calculator", "false").put("statistics-precalculation-for-pushdown.enabled", "true").put("collect-plan-statistics-for-all-queries", "true").put("optimizer.ignore-stats-calculator-failures", "false").put("optimizer.default-filter-factor-enabled", "true").put("optimizer.filter-conjunction-independence-factor", "1.0").put("join-distribution-type", "BROADCAST").put("join-max-broadcast-table-size", "42GB").put("optimizer.join-multi-clause-independence-factor", "0.75").put("optimizer.join-reordering-strategy", "NONE").put("optimizer.max-reordered-joins", "5").put("iterative-optimizer-timeout", "10s").put("enable-forced-exchange-below-group-id", "false").put("distributed-index-joins-enabled", "true").put("colocated-joins-enabled", "true").put("spatial-joins-enabled", "false").put("distributed-sort", "false").put("use-preferred-write-partitioning", "false").put("preferred-write-partitioning-min-number-of-partitions", "10").put("optimizer.optimize-metadata-queries", "true").put("optimizer.optimize-hash-generation", "false").put("optimizer.optimize-mixed-distinct-aggregations", "true").put("optimizer.push-table-write-through-union", "false").put("optimizer.dictionary-aggregation", "true").put("optimizer.push-aggregation-through-outer-join", "false").put("optimizer.push-partial-aggregation-through-join", "true").put("optimizer.enable-intermediate-aggregations", "true").put("optimizer.force-single-node-output", "false").put("optimizer.use-mark-distinct", "false").put("optimizer.prefer-partial-aggregation", "false").put("optimizer.optimize-top-n-ranking", "false").put("optimizer.skip-redundant-sort", "false").put("optimizer.complex-expression-pushdown.enabled", "false").put("optimizer.predicate-pushdown-use-table-properties", "false").put("optimizer.ignore-downstream-preferences", "true").put("optimizer.rewrite-filtering-semi-join-to-inner-join", "false").put("optimizer.optimize-duplicate-insensitive-joins", "false").put("optimizer.use-legacy-window-filter-pushdown", "true").put("optimizer.use-table-scan-node-partitioning", "false").put("optimizer.table-scan-node-partitioning-min-bucket-to-task-ratio", "0.0").put("optimizer.merge-project-with-values", "false").put("adaptive-partial-aggregation.enabled", "false").put("adaptive-partial-aggregation.min-rows", "1").put("adaptive-partial-aggregation.unique-rows-ratio-threshold", "0.99").buildOrThrow();
OptimizerConfig expected = new OptimizerConfig().setCpuCostWeight(0.4).setMemoryCostWeight(0.3).setNetworkCostWeight(0.2).setEnableStatsCalculator(false).setStatisticsPrecalculationForPushdownEnabled(true).setCollectPlanStatisticsForAllQueries(true).setIgnoreStatsCalculatorFailures(false).setJoinDistributionType(BROADCAST).setJoinMaxBroadcastTableSize(DataSize.of(42, GIGABYTE)).setJoinMultiClauseIndependenceFactor(0.75).setJoinReorderingStrategy(NONE).setMaxReorderedJoins(5).setIterativeOptimizerTimeout(new Duration(10, SECONDS)).setEnableForcedExchangeBelowGroupId(false).setDistributedIndexJoinsEnabled(true).setColocatedJoinsEnabled(true).setSpatialJoinsEnabled(false).setUsePreferredWritePartitioning(false).setPreferredWritePartitioningMinNumberOfPartitions(10).setDefaultFilterFactorEnabled(true).setFilterConjunctionIndependenceFactor(1.0).setOptimizeMetadataQueries(true).setOptimizeHashGeneration(false).setOptimizeMixedDistinctAggregations(true).setPushTableWriteThroughUnion(false).setDictionaryAggregation(true).setPushAggregationThroughOuterJoin(false).setPushPartialAggregationThoughJoin(true).setEnableIntermediateAggregations(true).setUseMarkDistinct(false).setPreferPartialAggregation(false).setOptimizeTopNRanking(false).setDistributedSortEnabled(false).setSkipRedundantSort(false).setComplexExpressionPushdownEnabled(false).setPredicatePushdownUseTableProperties(false).setIgnoreDownstreamPreferences(true).setRewriteFilteringSemiJoinToInnerJoin(false).setOptimizeDuplicateInsensitiveJoins(false).setUseLegacyWindowFilterPushdown(true).setUseTableScanNodePartitioning(false).setTableScanNodePartitioningMinBucketToTaskRatio(0.0).setMergeProjectWithValues(false).setForceSingleNodeOutput(false).setAdaptivePartialAggregationEnabled(false).setAdaptivePartialAggregationMinRows(1).setAdaptivePartialAggregationUniqueRowsRatioThreshold(0.99);
assertFullMapping(properties, expected);
}
use of io.trino.sql.planner.OptimizerConfig in project trino by trinodb.
the class TestAnalyzer method testTooManyGroupingElements.
@Test
public void testTooManyGroupingElements() {
Session session = testSessionBuilder(new SessionPropertyManager(new SystemSessionProperties(new QueryManagerConfig(), new TaskManagerConfig(), new MemoryManagerConfig(), new FeaturesConfig().setMaxGroupingSets(2048), new OptimizerConfig(), new NodeMemoryConfig(), new DynamicFilterConfig(), new NodeSchedulerConfig()))).build();
analyze(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, SUM(l)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k)");
assertFails(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, l, SUM(m)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k, l)").hasErrorCode(TOO_MANY_GROUPING_SETS).hasMessageMatching("line 3:10: GROUP BY has 4096 grouping sets but can contain at most 2048");
assertFails(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, SUM(af)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, " + "17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, af)\n" + "GROUP BY CUBE (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae)").hasErrorCode(TOO_MANY_GROUPING_SETS).hasMessageMatching(format("line 3:10: GROUP BY has more than %s grouping sets but can contain at most 2048", Integer.MAX_VALUE));
}
Aggregations