private static RelNode doTransform(SqlHandlerConfig config, final PlannerType plannerType, final PlannerPhase phase, final RelOptPlanner planner, final RelNode input, boolean log, Supplier<RelNode> toPlan) { final Stopwatch watch = Stopwatch.createStarted(); try { final RelNode output = toPlan.get(); if (log) { log(plannerType, phase, output, logger, watch); config.getObserver().planRelTransform(phase, planner, input, output, watch.elapsed(TimeUnit.MILLISECONDS)); } CALCITE_LOGGER.trace("Completed Phase: {}.", phase); return output; } catch (Throwable t) { // log our input state as oput anyway so we can ensure that we have details. try { log(plannerType, phase, input, logger, watch); config.getObserver().planRelTransform(phase, planner, input, input, watch.elapsed(TimeUnit.MILLISECONDS)); } catch (Throwable unexpected) { t.addSuppressed(unexpected); } throw t; } }
private static RelNode toConvertibleRelRoot(SqlHandlerConfig config, final SqlNode validatedNode, boolean expand, RelTransformer relTransformer) { final Stopwatch stopwatch = Stopwatch.createStarted(); final RelRootPlus convertible = config.getConverter().toConvertibleRelRoot(validatedNode, expand); config.getObserver().planConvertedToRel(convertible.rel, stopwatch.elapsed(TimeUnit.MILLISECONDS)); final RelNode reduced = relTransformer.transform(transform(config, PlannerType.HEP, PlannerPhase.REDUCE_EXPRESSIONS, convertible.rel, convertible.rel.getTraitSet(), true)); config.getObserver().planSerializable(reduced); return reduced; }
public ExplainHandler(SqlHandlerConfig config) { super(); this.config = new SqlHandlerConfig(config.getContext(), config.getConverter(), config.getObserver(), config.getMaterializations().orNull()); }
config.getObserver().tablesCollected(catalog.getAllRequestedTables()); final Optional<SubstitutionInfo> acceleration = findUsedMaterializations(config, drel); if (acceleration.isPresent()) { config.getObserver().planAccelerated(acceleration.get());
private static Pair<SqlNode, RelDataType> validateNode(SqlHandlerConfig config, final SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException { final Stopwatch stopwatch = Stopwatch.createStarted(); final SqlNode sqlNodeValidated; try { sqlNodeValidated = config.getConverter().validate(sqlNode); } catch (final Throwable ex) { throw new ValidationException("unable to validate sql node", ex); } final Pair<SqlNode, RelDataType> typedSqlNode = new Pair<>(sqlNodeValidated, config.getConverter().getOutputType(sqlNodeValidated)); // Check if the unsupported functionality is used UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(config.getContext()); try { sqlNodeValidated.accept(visitor); } catch (UnsupportedOperationException ex) { // If the exception due to the unsupported functionalities visitor.convertException(); // If it is not, let this exception move forward to higher logic throw ex; } config.getObserver().planValidated(typedSqlNode.getValue(), typedSqlNode.getKey(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); return typedSqlNode; }
if (logger.isDebugEnabled() || config.getObserver() != null) { textPlan = PrelSequencer.setPlansWithIds(phyRelNode, SqlExplainLevel.ALL_ATTRIBUTES, config.getObserver(), finalPrelTimer.elapsed(TimeUnit.MILLISECONDS)); if (logger.isDebugEnabled()) { logger.debug(String.format("%s:\n%s", "Final Physical Transformation", textPlan)); config.getObserver().finalPrel(phyRelNode); return Pair.of(phyRelNode, textPlan);
final AttemptObserver observer = config.getObserver(); ReflectionService service = config.getContext().getAccelerationManager().unwrap(ReflectionService.class);
substitutions.setObserver(config.getObserver()); substitutions.setEnabled(phase.useMaterializations); substitutions.setPostSubstitutionTransformer(
final AttemptObserver observer = config.getObserver();
finalConvertedNode = jdbcPushed.accept(new ShortenJdbcColumnAliases()).accept(new ConvertJdbcLogicalToJdbcRel()); config.getObserver().planRelTransform(PlannerPhase.JDBC_PUSHDOWN, null, convertedNode, finalConvertedNode, stopwatch.elapsed(TimeUnit.MILLISECONDS));