Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-22816

QueryCache: Queries using views can have them cached after CTE expansion

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0
    • Component/s: Query Processor
    • Labels:
      None

      Description

      create view ss_null as select * from store_Sales where ss_Sold_date_sk is null;
      
      select count(ss_ticket_number) from ss_null;
      
      with ss_null_cte as 
      (select * from store_Sales where ss_Sold_date_sk is null)
      select count(ss_ticket_number) from ss_null_cte;
      

      Are treated differently by the query cache, however their execution is identical.

      CBO rewrites the view query into AST form as follows

      SELECT COUNT(`ss_ticket_number`) AS `$f0`
      FROM `tpcds_bin_partitioned_acid_orc_10000`.`store_sales`
      WHERE `ss_sold_date_sk` IS NULL
      

      But retains the write-entity for the VIRTUAL_VIEW for Ranger authorization

      0: jdbc:hive2://localhost:10013> explain dependency select count(distinct ss_ticket_number) from ss_null;
      
      +----------------------------------------------------+
      |                      Explain                       |
      +----------------------------------------------------+
      | {"input_tables":[{"tablename":"tpcds_bin_partitioned_acid_orc_10000@ss_null","tabletype":"VIRTUAL_VIEW"},{"tablename":"tpcds_bin_partitioned_acid_orc_10000@store_sales","tabletype":"MANAGED_TABLE","tableParents":"[tpcds_bin_partitioned_acid_orc_10000@ss_null]"}],"input_partitions":[{"partitionName":"tpcds_bin_partitioned_acid_orc_10000@store_sales@ss_sold_date_sk=__HIVE_DEFAULT_PARTITION__"}]} |
      +----------------------------------------------------+
      

      Causing Query cache to print out

      parse.CalcitePlanner: Not eligible for results caching - query contains non-transactional tables [ss_null]
      

        Attachments

        1. HIVE-22816.1.patch
          0.7 kB
          Gopal Vijayaraghavan

          Activity

            People

            • Assignee:
              gopalv Gopal Vijayaraghavan
              Reporter:
              gopalv Gopal Vijayaraghavan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: