betodealmeida opened a new pull request #8470: Allow user to customize query 
cost estimate
URL: https://github.com/apache/incubator-superset/pull/8470
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [X] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   https://github.com/apache/incubator-superset/pull/8172 introduced the 
ability to estimate query costs before running them. Currently, this is 
supported by Presto, and it returns a _relative_ CPU and network cost.
   
   Ideally, we want to show the cost as dollars, time or percentile, instead of 
showing relative costs. Since the relationship between the relative cost and 
the actual cost varies from infrastructure to infrastructure, we need to 
provide users a way of customizing the query cost estimate.
   
   Here's a hypothetical example where we use a coefficient to compute the 
query cost in dollars based on CPU and network cost:
   
   ```python
   def presto_query_cost_formatter(result):
       cpu_coefficient = 1e-12
       network_coefficient = 1e-12
   
       cost = 0
       for row in result:
           cost += row.get("cpuCost", 0) * cpu_coefficient
           cost += row.get("networkCost", 0) * network_coefficient
   
       return [{"Cost": f"US$ {cost:.2f}"}]
   
   
   DEFAULT_FEATURE_FLAGS = {
       "ESTIMATE_QUERY_COST": True,
       "QUERY_COST_FORMATTER": {"presto": presto_query_cost_formatter},
   }
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   <img width="1680" alt="Screen Shot 2019-10-29 at 1 36 24 PM" 
src="https://user-images.githubusercontent.com/1534870/67808096-3fbb9b80-fa53-11e9-8ba4-59ef49c1c348.png";>
   
   ### TEST PLAN
   <!--- What steps should be taken to verify the changes -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ### REVIEWERS
   
   @khtruong 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to