Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-22253 General task tracking improvements for materialized views
  3. HIVE-22260

Materialized view rewriting does not support `UNION` operator, exact match can work under view

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: None
    • Component/s: CBO, Materialized views
    • Labels:
      None

      Description

      In this case, a view can be created that hides some nastier syntax like a "union".  

      A materialized view can contain the view with a simple query.  So if the end query just uses the view, it should rewrite to the materialized view. 

      Furthermore, an exception is thrown when it contains the "union" while creating the view.  At a minimum, we should print a friendlier message when the rewrite fails.

      A script is attached.

      An example of this:

      create view logical_complex0 as

      with t as

      (select c1 as a, c2 as b from tab1 where c2 in (select f from logical_simple where g > 0)

      union

      select tab3.c1 as c, tab4.c2 as d from tab3, tab4 where tab3.c2 = tab4.c2)

      select a, b

      from t;

       

      – query separator

       

      create materialized view aview_complex0 stored as orc as

      select a as x, b as y, count

      from logical_complex0

      group by 1, 2;

        Attachments

        1. complex0.sql
          2 kB
          Steve Carlin

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              scarlin Steve Carlin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: