use of org.apache.drill.exec.metastore.ColumnNamesOptions in project drill by apache.
the class MetastoreAnalyzeTableHandler method getPlan.
@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 (`metastore.enabled` is set to false)").build(logger);
}
// disables during analyze to prevent using data about locations from the Metastore
context.getOptions().setLocalOption(ExecConstants.METASTORE_ENABLED, false);
SqlMetastoreAnalyzeTable sqlAnalyzeTable = unwrap(sqlNode, SqlMetastoreAnalyzeTable.class);
SqlNode tableRef = sqlAnalyzeTable.getTableRef();
DrillTableInfo drillTableInfo = DrillTableInfo.getTableInfoHolder(tableRef, config);
AnalyzeInfoProvider analyzeInfoProvider = drillTableInfo.drillTable().getGroupScan().getAnalyzeInfoProvider();
if (analyzeInfoProvider == null) {
throw UserException.validationError().message("ANALYZE is not supported for group scan [%s]", drillTableInfo.drillTable().getGroupScan()).build(logger);
}
ColumnNamesOptions columnNamesOptions = new ColumnNamesOptions(context.getOptions());
// creates select with DYNAMIC_STAR column and analyze specific columns to obtain corresponding table scan
SqlSelect scanSql = new SqlSelect(SqlParserPos.ZERO, SqlNodeList.EMPTY, getColumnList(analyzeInfoProvider.getProjectionFields(drillTableInfo.drillTable(), getMetadataType(sqlAnalyzeTable), columnNamesOptions)), tableRef, null, null, null, null, null, null, null);
ConvertedRelNode convertedRelNode = validateAndConvert(rewrite(scanSql));
RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
RelNode relScan = convertedRelNode.getConvertedNode();
DrillRel drel = convertToDrel(relScan, sqlAnalyzeTable, drillTableInfo);
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;
}
Aggregations