Bug #72180 Visual explain: unexpected node in grouping_operation: buffer_result
Submitted: 1 Apr 2014 8:19 Modified: 15 May 2014 0:46
Reporter: Fredric Johansson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:6.1.4 OS:Any
Assigned to: CPU Architecture:Any

[1 Apr 2014 8:19] Fredric Johansson
Description:
When trying to do a visual explain on the following query, the JSON output contains a "buffer_result" node which causes an unexpected node error.

--SQL:
SELECT GROUP_CONCAT(DISTINCT plate_id) plates
FROM content
JOIN transition st USING (transition_id)
WHERE state=950
GROUP BY ab
ORDER BY plates;

--JSON output:
{
  "query_block": {
    "select_id": 1,
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": true,
        "buffer_result": {
          "using_temporary_table": true,
          "nested_loop": [
            {
              "table": {
                "table_name": "st",
                "access_type": "ref",
                "possible_keys": [
                  "PRIMARY",
                  "state_idx",
                  "state_st_idx"
                ],
                "key": "state_st_idx",
                "used_key_parts": [
                  "state"
                ],
                "key_length": "4",
                "ref": [
                  "const"
                ],
                "rows": 26889,
                "filtered": 100,
                "using_index": true
              }
            },
            {
              "table": {
                "table_name": "content",
                "access_type": "ref",
                "possible_keys": [
                  "ab_ce_idx",
                  "transition_idx",
                  "ab_plate_templ_idx"
                ],
                "key": "transition_idx",
                "used_key_parts": [
                  "transition_id"
                ],
                "key_length": "4",
                "ref": [
                  "transition_id"
                ],
                "rows": 1,
                "filtered": 100
              }
            }
          ]
        }
      }
    }
  }
}

--Workbench log:
09:34:09 [ERR][explain_renderer.py:unexpected:1235]: While parsing JSON output: unexpected node in grouping_operation: buffer_result
09:34:09 [ERR][         python]: error calling SQLIDEQueryAnalysis.visualExplainTraceback (most recent call last):
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_query_analysis_grt.py", line 388, in visualExplain
09:34:09 [ERR][         python]:     view = ExplainTab(version, statement, json, explain if explain else None)
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_query_analysis_grt.py", line 282, in __init__
09:34:09 [ERR][         python]:     self._query_plan.drawbox.relayout()
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_query_analysis_grt.py", line 106, in relayout
09:34:09 [ERR][         python]:     w, h = self.econtext.layout()
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\explain_renderer.py", line 1505, in layout
09:34:09 [ERR][         python]:     self._root.do_relayout(c)
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\explain_renderer.py", line 972, in do_relayout
09:34:09 [ERR][         python]:     child.do_relayout(ctx)
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\explain_renderer.py", line 855, in do_relayout
09:34:09 [ERR][         python]:     child.do_relayout(ctx)
09:34:09 [ERR][         python]:   File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\explain_renderer.py", line 855, in do_relayout
09:34:09 [ERR][         python]:     child.do_relayout(ctx)
09:34:09 [ERR][         python]: AttributeError: 'NoneType' object has no attribute 'do_relayout'
09:34:09 [ERR][            grt]: Error executing plugin wb.sqlide.visual_explain: error calling Python module function SQLIDEQueryAnalysis.visualExplain	
09:34:09 [ERR][      WBContext]: error calling Python module function SQLIDEQueryAnalysis.visualExplain

How to repeat:
Run the json through the explain renderer
[8 Apr 2014 11:12] MySQL Verification Team
Hello Fredric,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[8 Apr 2014 11:16] MySQL Verification Team
// How to repeat

use test;
CREATE TABLE `user` (
	`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
	`name` varchar(30) NOT NULL,
	`course` smallint(5) unsigned DEFAULT NULL,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE TABLE `course` (
	`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
	`name` varchar(50) NOT NULL,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB;

insert into course values(1,'MySQL'),(2,'Oracle');
insert into user values(1,'user1',1);
insert into user values(2,'user1',2);
insert into user values(3,'user2',1);
insert into user values(4,'user3',1);

// Now try below query with Visual Explain

SELECT group_concat(user.name), course.name FROM `user` INNER JOIN `course` on user.course = course.id group by course.id ORDER BY user.name;

// See error log

16:41:00 [ERR][explain_renderer.py:unexpected:1235]: While parsing JSON output: unexpected node in grouping_operation: buffer_result
16:41:00 [ERR][         python]: error calling SQLIDEQueryAnalysis.visualExplainTraceback (most recent call last):
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\wb_query_analysis_grt.py", line 388, in visualExplain
16:41:00 [ERR][         python]:     view = ExplainTab(version, statement, json, explain if explain else None)
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\wb_query_analysis_grt.py", line 282, in __init__
16:41:00 [ERR][         python]:     self._query_plan.drawbox.relayout()
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\wb_query_analysis_grt.py", line 106, in relayout
16:41:00 [ERR][         python]:     w, h = self.econtext.layout()
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\explain_renderer.py", line 1505, in layout
16:41:00 [ERR][         python]:     self._root.do_relayout(c)
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\explain_renderer.py", line 972, in do_relayout
16:41:00 [ERR][         python]:     child.do_relayout(ctx)
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\explain_renderer.py", line 855, in do_relayout
16:41:00 [ERR][         python]:     child.do_relayout(ctx)
16:41:00 [ERR][         python]:   File "D:\WB\MySQL Workbench 6.1.4 CE\modules\explain_renderer.py", line 855, in do_relayout
16:41:00 [ERR][         python]:     child.do_relayout(ctx)
16:41:00 [ERR][         python]: AttributeError: 'NoneType' object has no attribute 'do_relayout'
16:41:00 [ERR][            grt]: Error executing plugin wb.sqlide.visual_explain: error calling Python module function SQLIDEQueryAnalysis.visualExplain	
16:41:00 [ERR][      WBContext]: error calling Python module function SQLIDEQueryAnalysis.visualExplain
[15 May 2014 0:46] Philip Olson
Fixed as of the upcoming MySQL Workbench 6.1.6 release, and here's the changelog entry:

When generating a Visual Explain report, a group operation would cause the
generated JSON output to contain a node error.

Thank you for the bug report.