Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
-- create external table
create external table ext (a integer);

-- see where the table lives:
desc formatted t;
[...]
| Location:                     | file:/data/hive/warehouse/ext                       | NULL                                               |
[...]

-- in a terminal; load some data into the table directory:
seq 1 10 > /data/hive/warehouse/ext/f1

-- back in hive you will see that 
select count(1) from ext;
10
-- meanwhile basic stats show that the table has "0" rows 
desc formatted ext;
[...]
|                               | numRows                                            | 0                                                  |
[...]

create scheduled query ext_analyze cron '0 */1 * * * ? *' as analyze table ext compute statistics for columns;

-- wait some time or execute by issuing:
alter scheduled query ext_analyze execute;


select * from information_schema.scheduled_executions s where schedule_name='ex_analyze' order by scheduled_execution_id desc limit 3;
+---------------------------+------------------+----------------------------------------------------+------------+----------------------+----------------------+------------+------------------+----------------------+
| s.scheduled_execution_id  | s.schedule_name  |                s.executor_query_id                 |  s.state   |     s.start_time     |      s.end_time      | s.elapsed  | s.error_message  |  s.last_update_time  |
+---------------------------+------------------+----------------------------------------------------+------------+----------------------+----------------------+------------+------------------+----------------------+
| 498                       | ext_analyze       | dev_20200203152640_a59bc198-3ed3-4ef2-8f63-573607c9914e | FINISHED   | 2020-02-03 15:26:38  | 2020-02-03 15:28:01  | 83         | NULL             | NULL                 |
+---------------------------+------------------+----------------------------------------------------+------------+----------------------+----------------------+------------+------------------+----------------------+

-- and the numrows have been updated
desc formatted ext;
[...]
|                               | numRows                                            | 10                                                 |
[...]


-- we don't want this running every minute anymore...
alter scheduled query ext_analyze disable;




Example 3 – materialized view rebuild

...