@Override
    public void validate(PlanNode plan, Session session, Metadata metadata, SqlParser sqlParser, TypeProvider types, WarningCollector warningCollector)
    {
        int outputPlanNodesCount = searchFrom(plan)
                .where(OutputNode.class::isInstance)
                .findAll()
                .size();
        checkState(outputPlanNodesCount == 1, "Expected plan to have single instance of OutputNode");
    }
@Test(expectedExceptions = IllegalStateException.class)
    public void testValidateFailed()
    {
        // random plan with 2 output nodes
        PlanNode root =
                new OutputNode(Optional.empty(), idAllocator.getNextId(),
                        new ExplainAnalyzeNode(Optional.empty(), idAllocator.getNextId(),
                                new OutputNode(Optional.empty(), idAllocator.getNextId(),
                                        new ProjectNode(idAllocator.getNextId(),
                                                new ValuesNode(Optional.empty(),
                                                        idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of(), Optional.empty()),
                                                Assignments.of()
                                        ), ImmutableList.of(), ImmutableList.of()
                                ), new VariableReferenceExpression(Optional.empty(), "a", BIGINT),
                                false,
                                ExplainFormat.Type.TEXT),
                        ImmutableList.of(), ImmutableList.of());
        new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
    }