[
https://issues.apache.org/jira/browse/DRILL-7273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16971671#comment-16971671
]
ASF GitHub Bot commented on DRILL-7273:
---------------------------------------
vvysotskyi commented on pull request #1886: DRILL-7273: Introduce operators for
handling metadata
URL: https://github.com/apache/drill/pull/1886#discussion_r344199861
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/MetastoreAnalyzeTableHandler.java
##########
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.drill.exec.planner.sql.handlers;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.TableScan;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlNumericLiteral;
+import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.tools.RelBuilder;
+import org.apache.calcite.tools.RelConversionException;
+import org.apache.calcite.tools.ValidationException;
+import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.expression.FieldReference;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.logical.data.NamedExpression;
+import org.apache.drill.common.util.function.CheckedSupplier;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.metastore.analyze.AnalyzeInfoProvider;
+import org.apache.drill.exec.metastore.analyze.MetadataAggregateContext;
+import org.apache.drill.exec.metastore.analyze.MetadataControllerContext;
+import org.apache.drill.exec.metastore.analyze.MetadataHandlerContext;
+import org.apache.drill.exec.metastore.analyze.MetadataInfoCollector;
+import org.apache.drill.exec.metastore.analyze.MetastoreAnalyzeConstants;
+import org.apache.drill.exec.metastore.analyze.TableType;
+import org.apache.drill.exec.physical.PhysicalPlan;
+import org.apache.drill.exec.physical.base.PhysicalOperator;
+import org.apache.drill.exec.planner.logical.DrillAnalyzeRel;
+import org.apache.drill.exec.planner.logical.DrillRel;
+import org.apache.drill.exec.planner.logical.DrillScreenRel;
+import org.apache.drill.exec.planner.logical.DrillTable;
+import org.apache.drill.exec.planner.logical.MetadataAggRel;
+import org.apache.drill.exec.planner.logical.MetadataControllerRel;
+import org.apache.drill.exec.planner.logical.MetadataHandlerRel;
+import org.apache.drill.exec.planner.physical.PlannerSettings;
+import org.apache.drill.exec.planner.physical.Prel;
+import org.apache.drill.exec.planner.sql.SchemaUtilites;
+import org.apache.drill.exec.planner.sql.parser.SqlMetastoreAnalyzeTable;
+import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.store.dfs.FormatSelection;
+import org.apache.drill.exec.util.Pointer;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
+import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
+import org.apache.drill.metastore.components.tables.BasicTablesRequests;
+import org.apache.drill.metastore.components.tables.MetastoreTableInfo;
+import org.apache.drill.metastore.metadata.MetadataInfo;
+import org.apache.drill.metastore.metadata.MetadataType;
+import org.apache.drill.metastore.metadata.TableInfo;
+import
org.apache.drill.shaded.guava.com.google.common.collect.ArrayListMultimap;
+import org.apache.drill.shaded.guava.com.google.common.collect.Multimap;
+import org.apache.parquet.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static
org.apache.drill.exec.planner.logical.DrillRelFactories.LOGICAL_BUILDER;
+
+/**
+ * Constructs plan to be executed for collecting metadata and storing it to
the metastore.
+ */
+public class MetastoreAnalyzeTableHandler extends DefaultSqlHandler {
+ private static final Logger logger =
LoggerFactory.getLogger(MetastoreAnalyzeTableHandler.class);
+
+ public MetastoreAnalyzeTableHandler(SqlHandlerConfig config, Pointer<String>
textPlan) {
+ super(config, textPlan);
+ }
+
+ @Override
+ public PhysicalPlan getPlan(SqlNode sqlNode)
+ throws ValidationException, RelConversionException, IOException,
ForemanSetupException {
+ if
(!context.getOptions().getOption(ExecConstants.METASTORE_ENABLED_VALIDATOR)) {
+ throw UserException.validationError()
+ .message("Running ANALYZE TABLE REFRESH METADATA command when
metastore is disabled")
+ .build(logger);
+ }
+ try {
+ // disables during analyze to prevent using locations from the metastore
+ context.getOptions().setLocalOption(ExecConstants.METASTORE_ENABLED,
false);
+ SqlMetastoreAnalyzeTable sqlAnalyzeTable = unwrap(sqlNode,
SqlMetastoreAnalyzeTable.class);
+
+ AbstractSchema drillSchema = SchemaUtilites.resolveToDrillSchema(
+ config.getConverter().getDefaultSchema(),
sqlAnalyzeTable.getSchemaPath());
+ DrillTable table = getDrillTable(drillSchema, sqlAnalyzeTable.getName());
+
+ AnalyzeInfoProvider analyzeInfoProvider =
AnalyzeInfoProvider.getAnalyzeInfoProvider(TableType.getTableType(table.getGroupScan()));
+
+ SqlIdentifier tableIdentifier = sqlAnalyzeTable.getTableIdentifier();
+ SqlSelect scanSql = new SqlSelect(
+ SqlParserPos.ZERO,
+ SqlNodeList.EMPTY,
+ getColumnList(sqlAnalyzeTable, analyzeInfoProvider),
+ tableIdentifier,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ ConvertedRelNode convertedRelNode = validateAndConvert(rewrite(scanSql));
+ RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
+
+ RelNode relScan = convertedRelNode.getConvertedNode();
+
+ DrillRel drel = convertToDrel(relScan, drillSchema, table,
sqlAnalyzeTable);
+
+ Prel prel = convertToPrel(drel, validatedRowType);
+ logAndSetTextPlan("Drill Physical", prel, logger);
+ PhysicalOperator pop = convertToPop(prel);
+ PhysicalPlan plan = convertToPlan(pop);
+ log("Drill Plan", plan, logger);
+ return plan;
+ } finally {
+ context.getOptions().setLocalOption(ExecConstants.METASTORE_ENABLED,
true);
Review comment:
No, it is not required, thanks, removed it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
> Create operator for handling metadata
> -------------------------------------
>
> Key: DRILL-7273
> URL: https://issues.apache.org/jira/browse/DRILL-7273
> Project: Apache Drill
> Issue Type: Sub-task
> Reporter: Arina Ielchiieva
> Assignee: Vova Vysotskyi
> Priority: Major
> Labels: doc-impacting
> Fix For: 1.17.0
>
>
> As described in the design document for [File metastore table
> metadata|https://docs.google.com/document/d/14pSIzKqDltjLEEpEebwmKnsDPxyS_6jGrPOjXu6M_NM/edit#heading=h.j079wdhtehuk]
> it is required to create an operator for handling metadata to be able to do
> incremental analyze.
> Add options:
> metastore.enabled
> metastore.metadata.store.depth_level
> Statement:
> ANALYZE TABLE REFRESH METADATA ...
--
This message was sent by Atlassian Jira
(v8.3.4#803005)