|
61 | 61 | import io.trino.sql.analyzer.Analysis;
|
62 | 62 | import io.trino.sql.analyzer.Analyzer;
|
63 | 63 | import io.trino.sql.analyzer.AnalyzerFactory;
|
| 64 | +import io.trino.sql.dialect.trino.ProgramBuilder; |
| 65 | +import io.trino.sql.newir.FormatOptions; |
64 | 66 | import io.trino.sql.planner.AdaptivePlanner;
|
65 | 67 | import io.trino.sql.planner.InputExtractor;
|
66 | 68 | import io.trino.sql.planner.LogicalPlanner;
|
@@ -148,6 +150,7 @@ public class SqlQueryExecution
|
148 | 150 | private final EventDrivenTaskSourceFactory eventDrivenTaskSourceFactory;
|
149 | 151 | private final TaskDescriptorStorage taskDescriptorStorage;
|
150 | 152 | private final PlanOptimizersStatsCollector planOptimizersStatsCollector;
|
| 153 | + private final FormatOptions formatOptions; |
151 | 154 |
|
152 | 155 | private SqlQueryExecution(
|
153 | 156 | PreparedQuery preparedQuery,
|
@@ -185,7 +188,8 @@ private SqlQueryExecution(
|
185 | 188 | SqlTaskManager coordinatorTaskManager,
|
186 | 189 | ExchangeManagerRegistry exchangeManagerRegistry,
|
187 | 190 | EventDrivenTaskSourceFactory eventDrivenTaskSourceFactory,
|
188 |
| - TaskDescriptorStorage taskDescriptorStorage) |
| 191 | + TaskDescriptorStorage taskDescriptorStorage, |
| 192 | + FormatOptions formatOptions) |
189 | 193 | {
|
190 | 194 | try (SetThreadName _ = new SetThreadName("Query-" + stateMachine.getQueryId())) {
|
191 | 195 | this.slug = requireNonNull(slug, "slug is null");
|
@@ -240,6 +244,7 @@ private SqlQueryExecution(
|
240 | 244 | this.eventDrivenTaskSourceFactory = requireNonNull(eventDrivenTaskSourceFactory, "taskSourceFactory is null");
|
241 | 245 | this.taskDescriptorStorage = requireNonNull(taskDescriptorStorage, "taskDescriptorStorage is null");
|
242 | 246 | this.planOptimizersStatsCollector = requireNonNull(planOptimizersStatsCollector, "planOptimizersStatsCollector is null");
|
| 247 | + this.formatOptions = requireNonNull(formatOptions, "formatOptions is null"); |
243 | 248 | }
|
244 | 249 | }
|
245 | 250 |
|
@@ -503,6 +508,13 @@ private PlanRoot doPlanQuery(CachingTableStatsProvider tableStatsProvider)
|
503 | 508 | Plan plan = logicalPlanner.plan(analysis);
|
504 | 509 | queryPlan.set(plan);
|
505 | 510 |
|
| 511 | + try { |
| 512 | + System.out.println(ProgramBuilder.buildProgram(plan.getRoot()).print(1, formatOptions)); |
| 513 | + } |
| 514 | + catch (UnsupportedOperationException e) { |
| 515 | + System.out.println("query not supported in the new IR: " + e.getMessage()); |
| 516 | + } |
| 517 | + |
506 | 518 | // fragment the plan
|
507 | 519 | SubPlan fragmentedPlan;
|
508 | 520 | try (var _ = scopedSpan(tracer, "fragment-plan")) {
|
@@ -809,6 +821,7 @@ public static class SqlQueryExecutionFactory
|
809 | 821 | private final ExchangeManagerRegistry exchangeManagerRegistry;
|
810 | 822 | private final EventDrivenTaskSourceFactory eventDrivenTaskSourceFactory;
|
811 | 823 | private final TaskDescriptorStorage taskDescriptorStorage;
|
| 824 | + private final FormatOptions formatOptions; |
812 | 825 |
|
813 | 826 | @Inject
|
814 | 827 | SqlQueryExecutionFactory(
|
@@ -841,7 +854,8 @@ public static class SqlQueryExecutionFactory
|
841 | 854 | SqlTaskManager coordinatorTaskManager,
|
842 | 855 | ExchangeManagerRegistry exchangeManagerRegistry,
|
843 | 856 | EventDrivenTaskSourceFactory eventDrivenTaskSourceFactory,
|
844 |
| - TaskDescriptorStorage taskDescriptorStorage) |
| 857 | + TaskDescriptorStorage taskDescriptorStorage, |
| 858 | + FormatOptions formatOptions) |
845 | 859 | {
|
846 | 860 | this.tracer = requireNonNull(tracer, "tracer is null");
|
847 | 861 | this.schedulerStats = requireNonNull(schedulerStats, "schedulerStats is null");
|
@@ -875,6 +889,7 @@ public static class SqlQueryExecutionFactory
|
875 | 889 | this.exchangeManagerRegistry = requireNonNull(exchangeManagerRegistry, "exchangeManagerRegistry is null");
|
876 | 890 | this.eventDrivenTaskSourceFactory = requireNonNull(eventDrivenTaskSourceFactory, "eventDrivenTaskSourceFactory is null");
|
877 | 891 | this.taskDescriptorStorage = requireNonNull(taskDescriptorStorage, "taskDescriptorStorage is null");
|
| 892 | + this.formatOptions = requireNonNull(formatOptions, "formatOptions is null"); |
878 | 893 | }
|
879 | 894 |
|
880 | 895 | @Override
|
@@ -925,7 +940,8 @@ public QueryExecution createQueryExecution(
|
925 | 940 | coordinatorTaskManager,
|
926 | 941 | exchangeManagerRegistry,
|
927 | 942 | eventDrivenTaskSourceFactory,
|
928 |
| - taskDescriptorStorage); |
| 943 | + taskDescriptorStorage, |
| 944 | + formatOptions); |
929 | 945 | }
|
930 | 946 | }
|
931 | 947 | }
|
0 commit comments