zamar-roura opened a new pull request, #21325:
URL: https://github.com/apache/superset/pull/21325

   ### SUMMARY
   We are adding four methods inside superset/db_engine_specs/bigquery.py
   
   For now only Postgres and Presto had cost estimation capabilities. For that 
they used the **cursor** object. 
   Bigquery needs to use a **dry run** to get the query cost estimation. Sadly, 
you can't use the cursor to execute dry runs (I have tried). And that's why 
there is a need to override the two functions. **estimate_statement_cost** and 
**estimate_query_cost**. The other two methods **get_allow_cost_estimate**  and 
**query_cost_formatter** are just added because the base class doesn't have 
functionality or gives a False. 
   
   Also the QueryEditor.py object doesn't have sqlEditorId anymore in it's 
variables and the Cost Estimation Reducer is looking for it, thus giving error, 
that is also changed. 
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   BEFORE 
   
   
![image](https://user-images.githubusercontent.com/12966153/188329804-5b0d3b2c-997a-4cc3-8466-9b78d3f85599.png)
    
   After
   
![image](https://user-images.githubusercontent.com/12966153/188329839-637ee344-1023-408b-a108-351ae3f1a229.png)
   
   ### TESTING INSTRUCTIONS
   Add ESTIMATE_QUERY_COST = True inside superset/config.py.
   Add a valid BigQuery database, activate option *Enable query cost 
estimation* inside advanced options.
   Go to SQL Lab and put a valid query, then press Estimate Cost button.
   
   ### ADDITIONAL INFORMATION
   - [ X] Has associated issue: https://github.com/apache/superset/issues/20832
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ X] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to