View a hive with nested selections and crop sections

I have a view in HIVE with subselection - the purpose of the view is to remove duplicates from the source table.

The source table is separated by the source_system column.

CREATE VIEW myview AS SELECT * FROM ( SELECT * ,row_number() OVER (PARTITION BY source_system,key ORDER BY modification_date DESC) as seq_rn FROM mytable ) t WHERE seq_rn= 1 ; 

The problem is that if I do

 EXPLAIN DEPENDENCY SELECT * FROM myview WHERE source_system='AAA' 

I see that all partitions are checked, so partitions are not cropped.

Is there any way around this?

+6
source share
1 answer

Bypass

As mentioned in the last comment, you can create views for each filter.


Please note: the following does not help

As mentioned in the comments, this should be possible to solve using partitioned views as described here: https://cwiki.apache.org/confluence/display/Hive/PartitionedViews#PartitionedViews-Syntax

If partitioning does not apply to subqueries, try the following:

  • Make a request with an internal request
  • Take a second top view, with an external request

I would usually not advocate the creation of representations of representations, but if this is what is required in order to allow the work of sections, this, of course, would justify the choice of design.

+1
source

Source: https://habr.com/ru/post/1011782/


All Articles