Add support for ANALYZE FOR QUERY statement#12019
Add support for ANALYZE FOR QUERY statement#12019tangjiangling wants to merge 1 commit intotrinodb:masterfrom
ANALYZE FOR QUERY statement#12019Conversation
core/trino-main/src/main/java/io/trino/execution/CreateMaterializedViewTask.java
Outdated
Show resolved
Hide resolved
e1d9636 to
ea6b8dd
Compare
|
cc @wubiaoi |
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestAnalyzeForQuery.java
Outdated
Show resolved
Hide resolved
|
Once the code has been reviewed, I'll file a PR for the documentation. |
|
Run the following command (to check if I need to add additional tests) Results: So it looks like I still need to add PTs about Hive/Deltalake (I'm not sure if Deltalake needs to support this at the moment, see ) |
6f32546 to
31711db
Compare
|
(Rebased from master to resolve conflicts) |
31711db to
d0b314c
Compare
|
(Rebased from master to resolve conflicts) |
|
@findepi If you are available, please take a look at this PR. |
d0b314c to
bf585ab
Compare
bf585ab to
5fffdac
Compare
|
Marked this as a draft until #11517 (comment) is addressed. |
|
|
||
| // verify the target tables exists, and it's not all views | ||
| if (tableNames.isEmpty()) { | ||
| throw semanticException(NOT_SUPPORTED, node, "Analyzing views is not supported"); |
There was a problem hiding this comment.
I think this situation also occurs if you run a query like
ANALYZE FOR SELECT 123
So this error should probably be something like "No tables to analyze"
| .map(TableScanNode::getTable) | ||
| .forEach(tableHandle -> { | ||
| QualifiedObjectName tableName = metadata.getTableMetadata(session, tableHandle).getQualifiedName(); | ||
| if (!viewNames.contains(tableName)) { |
There was a problem hiding this comment.
Why do we need this logic? A TableScanNode will contain a TableHandle which is for the underlying table of a view. It should never itself be a view.
| * The returned table handle can contain information in tupleDomain. | ||
| */ | ||
| @Nullable | ||
| default ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSession session, SchemaTableName tableName, TupleDomain<ColumnHandle> tupleDomain) |
|
👋 @tangjiangling - this PR is inactive and doesn't seem to be under development. If you'd like to continue work on this at any point in the future, feel free to re-open. |
Description
New sql syntax.
Core query engine.
Allow user to execute the
ANALYZE FOR QUERYstatement to collect statistics on the granularity of the query.Related issues, pull requests, and links
Fixes #11517
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: