dengzhhu653 commented on code in PR #4536: URL: https://github.com/apache/hive/pull/4536#discussion_r1290816384
########## ql/src/test/queries/clientpositive/alter_table_column_stats.q: ########## @@ -265,3 +265,136 @@ drop table statsdb2.testtable2; use default; drop database statsdb1; drop database statsdb2; + +-- Test for external tables with hive.metastore.try.direct.sql.ddl as false +set hive.metastore.try.direct.sql.ddl=false; + +drop database if exists statsdb1; +create database statsdb1; +drop database if exists statsdb2; +create database statsdb2; + +create external table statsdb1.testtable0 (col1 int, col2 string, col3 string) row format delimited fields terminated by ',' stored as textfile tblproperties ('external.table.purge'='true'); +insert into statsdb1.testtable0 select key, value, 'val3' from src limit 10; + +create external table statsdb1.testpart0 (col1 int, col2 string, col3 string) partitioned by (part string) row format delimited fields terminated by ',' stored as textfile tblproperties ('external.table.purge'='true'); +insert into statsdb1.testpart0 partition (part = 'part1') select key, value, 'val3' from src limit 10; +insert into statsdb1.testpart0 partition (part = 'part2') select key, value, 'val3' from src limit 20; + +use statsdb1; +-- test non-partitioned table +analyze table testtable0 compute statistics for columns; +describe formatted statsdb1.testtable0; +describe formatted statsdb1.testtable0 col1; +describe formatted statsdb1.testtable0 col2; +describe formatted statsdb1.testtable0 col3; + +-- rename non-partitioned table should not change its table and columns stats +alter table statsdb1.testtable0 rename to statsdb1.testtable1; +describe formatted statsdb1.testtable1; +describe formatted statsdb1.testtable1 col1; +describe formatted statsdb1.testtable1 col2; +describe formatted statsdb1.testtable1 col3; + +-- when replacing columns in a non-partitioned table, the table stats should not change, +-- but the stats of the changed columns are removed +alter table testtable1 replace columns (col1 int, col2 string, col4 string); +describe formatted statsdb1.testtable1; +describe formatted statsdb1.testtable1 col1; +describe formatted statsdb1.testtable1 col2; +describe formatted statsdb1.testtable1 col4; + +-- when changing the column type in a non-partitioned table, the table stats should not change, +-- but the stats of the type-changed columns are removed +alter table testtable1 change col1 col1 string; +describe formatted statsdb1.testtable1; +describe formatted statsdb1.testtable1 col1; +describe formatted statsdb1.testtable1 col2; +describe formatted statsdb1.testtable1 col4; + +-- rename the db of a non-partitoned table, the table and columns stats should not change +alter table statsdb1.testtable1 rename to statsdb2.testtable2; +describe formatted statsdb2.testtable2; +describe formatted statsdb2.testtable2 col1; +describe formatted statsdb2.testtable2 col2; +describe formatted statsdb2.testtable2 col4; + +-- test partitioned table +analyze table testpart0 compute statistics for columns; +describe formatted statsdb1.testpart0; Review Comment: Hi @VenuReddy2103, follow the comments I know this is caused by stale stats after the alter, should we need so many `describe` statements in the tests? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org