shahidki31 opened a new pull request #32659:
URL: https://github.com/apache/spark/pull/32659


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: 
https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a 
faster review.
     7. If you want to add a new configuration, please read the guideline first 
for naming configurations in
        
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error message, please read the 
guideline first:
        https://spark.apache.org/error-message-guidelines.html
   -->
   
   ### What changes were proposed in this pull request?
   If the grouping keys contains substring, Aggregate doesn't use CBO for 
computing stats and fall back to sizeInBytes based estimation. So we will be 
missing row count and col stats after that. Many TPCDS queries has substring in 
their group by expressions, like Query8, Query23a etc.
   
   ### Why are the changes needed?
   CBO cannot estimate rowcount if the groupby clause of a query involves the 
expression substring. For example, we can not estimate the row count of the 
following query, extracted from TPC-DS queries and based on the TPC-DS schema:
   
   **Eg: Query**
   `SELECT item.i_brand, count(1), date_dim.d_year, item.i_brand_id, 
sum(store_sales.ss_ext_sales_price) AS ext_price, item.i_item_sk
   FROM store_sales INNER JOIN date_dim ON (date_dim.d_date_sk = 
store_sales.ss_sold_date_sk) INNER JOIN item ON (store_sales.ss_item_sk = 
item.i_item_sk)
   GROUP BY item.i_brand, date_dim.d_date, substring(item.i_item_desc, 1, 30), 
date_dim.d_year, item.i_brand_id, item.i_item_sk`
   
   **Before:**
   No rowcount
   
   
![image](https://user-images.githubusercontent.com/23054875/119455021-d26b0c00-bd56-11eb-8f96-1eff932da35d.png)
   
   **After:**
   
   Rowcount exists
   
   
![image](https://user-images.githubusercontent.com/23054875/119452969-9171f800-bd54-11eb-8486-ef7734996f23.png)
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Added UTs, manual testing
   


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



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

Reply via email to