Skip to main content
Question

Filtering in TopK projection definition

  • Apr 1, 2020 10:43 PM UTC
  • 1 reply
  • 9 views

DreaBrandford

Is it possible to add filters (WHERE condition) while using TOP-K Projections?

Asked during BDC session The Shortest Path to Vertica - Best Practices for Data Warehouse Migration & ETL
@marcothesane @Maurizio

1 reply

ChuckB
Forum|alt.badge.img
  • Participating Frequently
  • Apr 2, 2020 4:02 PM UTC

Not directly, but you can probably get equivalent benefits.
Top-K projections save a fixed number of rows per key, as defined by the PARTITION BY and ORDER BY clause of the Top K. If the WHERE clause you are thinking of applies to the PARTITION BY columns, this will run quite quickly because the projection is sorted on the PARTITION BY columns. If the WHERE clause was to keep rows out of the partition, you could down-rank them in the ORDER BY.