presto-main/src/main/java/io/prestosql/sql/planner/OutputExtractor.java/OutputExtractor/extractOutput
class OutputExtractor:    public Optional<Output> extractOutput(PlanNode root)
    {
        Visitor visitor = new Visitor();
        root.accept(visitor, null);

        if (visitor.getCatalogName() == null) {
            return Optional.empty();
        }

        return Optional.of(new Output(
                visitor.getCatalogName(),
                visitor.getSchemaTableName().getSchemaName(),
                visitor.getSchemaTableName().getTableName()));
    }