Support Questions
Find answers, ask questions, and share your expertise

External json table hive location

New Contributor

Here is the issue I am trying to solve:


I have a external table that reads from location stored in a date directory

- data/2020/05/01

- data/2020/05/02

- data/2020/05/03

- data/2020/05/04

- data/2020/05/05

- data/2020/05/06

- data/2020/05/07

- data/2020/05/08

- data/2020/05/09

- data/2020/05/10

etc...I need the external table to point to the last 7 days of data, last 14 days etc.

The following will read the date I specify in the variable...

ALTER TABLE date_test_stg SET LOCATION '/data/$date_yr/$date_mn/$date_day';

Is there a way to dynamically change the last 7 days?