prestodb/presto

EXPLAIN ANALYZE fails on queries with CTE materialization

Open

#23798 opened on Oct 9, 2024

View on GitHub
 (0 comments) (0 reactions) (1 assignee)Java (15,558 stars) (5,240 forks)batch import
bugcte_materializationgood first issue

Description

When running a simple query that uses CTE materialization, EXPLAIN ANALYZE on the query will fail

presto:tpcds> SET SESSION cte_materialization_strategy = 'ALL';
presto:tpcds> SET SESSION cte_partitioning_provider_catalog='hive';
presto:tpcds> SET SESSION hive.temporary_table_storage_format = 'PARQUET';
presto:tpcds> SET SESSION hive.temporary_table_schema = '__temp_ctes__';
presto:tpcds> EXPLAIN ANALYZE WITH t as (VALUES 1, 2, 3) SELECT * FROM t;

Query 20241009_221616_00054_s2xu9, FAILED, 4 nodes
Splits: 61 total, 52 done (85.25%)
[Latency: client-side: 178ms, server-side: 150ms] [6 rows, 692B] [40 rows/s, 4.5KB/s]

Query 20241009_221616_00054_s2xu9 failed: Expected one sub stage of explain node

Your Environment

  • HiveQueryRunner on MacOS

Session configuration

SET SESSION cte_materialization_strategy = 'ALL';
SET SESSION cte_partitioning_provider_catalog='hive';
SET SESSION hive.temporary_table_storage_format = 'PARQUET';
SET SESSION hive.temporary_table_schema = '__temp_ctes__';

Expected Behavior

We should get a valid EXPLAIN ANALYZE output

Possible Solution

We can probably generate a plan for each output stage and render them together? At least for json format it could be an array. In text format we could add some kind of separator?

Steps to Reproduce

  1. Start HiveQueryRunner
  2. Set session properties in description
  3. Execute SQL query in description

Context

EXPLAIN ANALYZE is useful for debugging queries. It should work when we turn on CTE materialization.

Contributor guide