Skip to content
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 a system table to list all ANALYZE properties #376

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
6 changes: 4 additions & 2 deletions presto-docs/src/main/sphinx/sql/analyze.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Description

Collects table and column statistics for a given table.

The optional ``WITH`` clause can be used to provide
connector-specific properties.
The optional ``WITH`` clause can be used to provide connector-specific properties.
To list all available properties, run the following query::

SELECT * FROM system.metadata.analyze_properties

Currently, this statement is only supported by the
:ref:`Hive connector <hive_analyze>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,14 @@ public void testCollectColumnStatisticsOnInsert()
assertUpdate(format("DROP TABLE %s", tableName));
}

@Test
public void testAnalyzePropertiesSystemTable()
{
assertQuery(
"SELECT * FROM system.metadata.analyze_properties WHERE catalog_name = 'hive'",
"SELECT 'hive', 'partitions', '', 'array(array(varchar))', 'Partitions to be analyzed'");
}

@Test
public void testAnalyzeEmptyTable()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.prestosql.connector.system;

import io.prestosql.metadata.Metadata;
import io.prestosql.transaction.TransactionManager;

import javax.inject.Inject;

public class AnalyzePropertiesSystemTable
extends AbstractPropertiesSystemTable
{
@Inject
public AnalyzePropertiesSystemTable(TransactionManager transactionManager, Metadata metadata)
{
super("analyze_properties", transactionManager, () -> metadata.getAnalyzePropertyManager().getAllProperties());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void configure(Binder binder)
globalTableBinder.addBinding().to(SchemaPropertiesSystemTable.class).in(Scopes.SINGLETON);
globalTableBinder.addBinding().to(TablePropertiesSystemTable.class).in(Scopes.SINGLETON);
globalTableBinder.addBinding().to(ColumnPropertiesSystemTable.class).in(Scopes.SINGLETON);
globalTableBinder.addBinding().to(AnalyzePropertiesSystemTable.class).in(Scopes.SINGLETON);
globalTableBinder.addBinding().to(TransactionsSystemTable.class).in(Scopes.SINGLETON);

globalTableBinder.addBinding().to(AttributeJdbcTable.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.prestosql.block.BlockEncodingManager;
import io.prestosql.connector.ConnectorId;
import io.prestosql.connector.ConnectorManager;
import io.prestosql.connector.system.AnalyzePropertiesSystemTable;
import io.prestosql.connector.system.CatalogSystemTable;
import io.prestosql.connector.system.ColumnPropertiesSystemTable;
import io.prestosql.connector.system.GlobalSystemConnector;
Expand Down Expand Up @@ -349,6 +350,7 @@ private LocalQueryRunner(Session defaultSession, FeaturesConfig featuresConfig,
new SchemaPropertiesSystemTable(transactionManager, metadata),
new TablePropertiesSystemTable(transactionManager, metadata),
new ColumnPropertiesSystemTable(transactionManager, metadata),
new AnalyzePropertiesSystemTable(transactionManager, metadata),
new TransactionsSystemTable(typeRegistry, transactionManager)),
ImmutableSet.of());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ system| information_schema| views| table_catalog| varchar| YES| null| null|
system| information_schema| views| table_schema| varchar| YES| null| null|
system| information_schema| views| table_name| varchar| YES| null| null|
system| information_schema| views| view_definition| varchar| YES| null| null|
system| metadata| analyze_properties| catalog_name| varchar| YES| null| null|
system| metadata| analyze_properties| property_name| varchar| YES| null| null|
system| metadata| analyze_properties| default_value| varchar| YES| null| null|
system| metadata| analyze_properties| type| varchar| YES| null| null|
system| metadata| analyze_properties| description| varchar| YES| null| null|
system| metadata| catalogs| catalog_name| varchar| YES| null| null|
system| metadata| catalogs| connector_id| varchar| YES| null| null|
system| metadata| column_properties| catalog_name| varchar| YES| null| null|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- delimiter: |; ignoreOrder: true;
catalogs|
analyze_properties|
schema_properties|
table_properties|
column_properties|
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public void testTooLongQuery()
assertQueryFails(longQuery, "Query text length \\(1000037\\) exceeds the maximum length \\(1000000\\)");
}

@Test
public void testAnalyzePropertiesSystemTable()
{
assertQuery("SELECT COUNT(*) FROM system.metadata.analyze_properties WHERE catalog_name = 'tpch'", "SELECT 0");
}

@Test
public void testAnalyze()
{
Expand Down