-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add native analyze e2e tests #20028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add native analyze e2e tests #20028
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,6 +190,44 @@ public void testFiltersAndProjections() | |
| assertQuery("SELECT if(orderkey % 2 = 0, quantity_by_linenumber) FROM orders_ex"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAnalyzeStats() | ||
| { | ||
| assertQuery("ANALYZE region"); | ||
| // presto:tpch> show stats for region; | ||
| // column_name | data_size | distinct_values_count | nulls_fraction | row_count | low_value | high_value | ||
| // -------------+-----------+-----------------------+----------------+-----------+-----------+------------ | ||
| // regionkey | NULL | 5.0 | 0.0 | NULL | 0 | 4 | ||
| // name | 34.0 | 5.0 | 0.0 | NULL | NULL | NULL | ||
| // comment | 330.0 | 5.0 | 0.0 | NULL | NULL | NULL | ||
| // NULL | NULL | NULL | NULL | 5.0 | NULL | NULL | ||
| // (4 rows) | ||
| assertQuery("SHOW STATS FOR region"); | ||
| // Create a partitioned table and run analyze on it. | ||
| String tmpTableName = generateRandomTableName(); | ||
| try { | ||
| getQueryRunner().execute(getSession(), String.format("CREATE TABLE %s (name VARCHAR, regionkey BIGINT," + | ||
| "nationkey BIGINT) WITH (partitioned_by = ARRAY['regionkey','nationkey'])", tmpTableName)); | ||
| Session writeSession = buildSessionForTableWrite(); | ||
| getQueryRunner().execute(writeSession, | ||
| String.format("INSERT INTO %s SELECT name, regionkey, nationkey FROM nation", tmpTableName)); | ||
| assertQuery(String.format("SELECT * FROM %s", tmpTableName), | ||
| "SELECT name, regionkey, nationkey FROM nation"); | ||
| assertQuery("ANALYZE %s WITH (partitions = ARRAY[ARRAY['0','0'],ARRAY['4', '11']])", tmpTableName); | ||
|
||
| // column_name | data_size | distinct_values_count | nulls_fraction | row_count | low_value | high_value | ||
| //-------------+-----------+-----------------------+----------------+-----------+-----------+------------ | ||
| // name | 137.5 | 1.0 | 0.0 | NULL | NULL | NULL | ||
| // regionkey | NULL | 5.0 | 0.0 | NULL | 0 | 4 | ||
| // nationkey | NULL | 25.0 | 0.0 | NULL | 0 | 24 | ||
| // NULL | NULL | NULL | NULL | 25.0 | NULL | NULL | ||
| // (4 rows) | ||
| assertQuery("SHOW STATS for %s", tmpTableName); | ||
| } | ||
| finally { | ||
| dropTableIfExists(tmpTableName); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testDateFilter() | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"nation" is a very tiny table for this kind of test. But its probably sufficient to test the correctness of this work.