Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,18 @@ std::string mapScalarFunction(const std::string& name) {
}

std::string mapAggregateOrWindowFunction(const std::string& name) {
return boost::to_lower_copy(name);
static const std::unordered_map<std::string, std::string> kFunctionNames = {
{"presto.default.$internal$max_data_size_for_stats",
"presto.default.max_data_size_for_stats"},
{"presto.default.$internal$sum_data_size_for_stats",
"presto.default.sum_data_size_for_stats"},
};
std::string lowerCaseName = boost::to_lower_copy(name);
auto it = kFunctionNames.find(name);
if (it != kFunctionNames.end()) {
return it->second;
}
return lowerCaseName;
}

std::string getFunctionName(const protocol::Signature& signature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,44 @@ public void testFiltersAndProjections()
assertQuery("SELECT if(orderkey % 2 = 0, quantity_by_linenumber) FROM orders_ex");
}

@Test
public void testAnalyzeStats()
{
assertUpdate("ANALYZE region", 5);

// Show stats returns the following stats for each column in region table:
// column_name | data_size | distinct_values_count | nulls_fraction | row_count | low_value | high_value
assertQuery("SHOW STATS FOR region",
"SELECT * FROM (VALUES" +
"('regionkey', NULL, 5.0, 0.0, NULL, '0', '4')," +
"('name', 54.0, 5.0, 0.0, NULL, NULL, NULL)," +
"('comment', 350.0, 5.0, 0.0, NULL, NULL, NULL)," +
"(NULL, NULL, NULL, NULL, 5.0, NULL, NULL))");

// Create a partitioned table and run analyze on it.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Please add a newline here.

String tmpTableName = generateRandomTableName();
try {
Session writeSession = buildSessionForTableWrite();
getQueryRunner().execute(writeSession, String.format("CREATE TABLE %s (name VARCHAR, regionkey BIGINT," +
"nationkey BIGINT) WITH (partitioned_by = ARRAY['regionkey','nationkey'])", tmpTableName));
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");
assertUpdate(String.format("ANALYZE %s", tmpTableName), 25);
assertQuery(String.format("SHOW STATS for %s", tmpTableName),
"SELECT * FROM (VALUES" +
"('name', 277.0, 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))");
// @TODO Add test for Analyze on table partitions. Refer: https://github.com/prestodb/presto/issues/20232
}
finally {
dropTableIfExists(tmpTableName);
}
}

@Test
public void testDateFilter()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ public void testTopN() {}
@Override
@Ignore
public void testInsertIntoSpecialPartitionName(){}

// @TODO Refer https://github.com/prestodb/presto/issues/20294
@Override
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Please add a newline between the tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@Ignore
public void testAnalyzeStats() {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ignored? Would you add a comment and perhaps refer to a GitHub issue that explains the problem.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aditi-pandit @karteekmurthys Would take a look at this question? I'm still wondering about this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have opened an issue that i faced during testing. Please refer L73.

}