Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally include warnings in EXPLAIN(TYPE IO) output #23864

Open
rschlussel opened this issue Oct 21, 2024 · 0 comments
Open

Optionally include warnings in EXPLAIN(TYPE IO) output #23864

rschlussel opened this issue Oct 21, 2024 · 0 comments
Assignees

Comments

@rschlussel
Copy link
Contributor

rschlussel commented Oct 21, 2024

Include a list of warnings in the explain (TYPE IO) output.

Currently in our production environment run explain(TYPE IO) before executing a query and use the result as input to our routing decisions. As part of getting the IO info, EXPLAIN (TYPE IO) generates the query plan, and therefore also has additional information about the planner warnings for the query. Include the warning information in the explain output as well so we can take advantage of the computation that has already been done in the original explain.

We can gate this by a session property include_warnings_in_explain_io_output

Expected Behavior or Use Case

Current behavior:

presto> EXPLAIN (TYPE IO) SELECT * FROM (SELECT * FROM tpch.sf1.nation order by n_nationkey) order by n_regionkey;
           Query Plan            
---------------------------------
 {                               
   "inputTableColumnInfos" : [ { 
     "table" : {                 
       "catalog" : "tpch",       
       "schemaTable" : {         
         "schema" : "sf1.0",     
         "table" : "nation"      
       }                         
     },                          
     "columnConstraints" : [ ]   
   } ]                           
 }                               

New result:

presto> EXPLAIN (TYPE IO) SELECT * FROM (SELECT * FROM tpch.sf1.nation order by n_nationkey) order by n_regionkey;
           Query Plan            
---------------------------------
 {                               
   "inputTableColumnInfos" : [ { 
     "table" : {                 
       "catalog" : "tpch",       
       "schemaTable" : {         
         "schema" : "sf1.0",     
         "table" : "nation"      
       }                         
     },                          
     "columnConstraints" : [ ]   
   } ],
  "warnings": [ {
  "warningCode" : {
    "code" : 5,
    "name" : "REDUNDANT_ORDER_BY"
  },
  "message" : "ORDER BY in subquery may have no effect"
} ]                        
 }                               

Presto Component, Service, or Connector

coordinator

Possible Implementation

Pass the warning collector from QueryExplainer into the IoPlanPrinter and then add the warnings to the explain output.

Example Screenshots (if appropriate):

Context

We plan to add custom warnings based on features supported in our different environments. We want to be able to use those warnings as input to our query routing decisions to determine which environment to route a query to. We'd like to reduce overhead by taking advantage of the explain(TYPE IO) that we are already calling and that is already getting this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant