Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table output EXPLAIN seems broken border because ambiguous width #61

Closed
apstndb opened this issue Jun 8, 2020 · 7 comments · Fixed by #62
Closed

Table output EXPLAIN seems broken border because ambiguous width #61

apstndb opened this issue Jun 8, 2020 · 7 comments · Fixed by #62

Comments

@apstndb
Copy link
Collaborator

apstndb commented Jun 8, 2020

The output of EXPLAIN with -t(--table) seems broken border in some environment.

$ spanner-cli -e "EXPLAIN SELECT * FROM Songs@{FORCE_INDEX=SongsBySongName}" -t
+--------------------------------------------------------------------------------------------------------+
| Query_Execution_Plan (EXPERIMENTAL)                                                                    |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                        |
| .                                                                                                      |
| └── Distributed Union (subquery_cluster_node: 1)                                                    |
|     └── Distributed Cross Apply (subquery_cluster_node: 15)                                         |
|         ├── Create Batch                                                                            |
|         │   └── Distributed Union (call_type: Local, subquery_cluster_node: 4)                     |
|         │       └── Compute Struct                                                                 |
|         │           └── Scan (scan_target: SongsBySongName, scan_type: IndexScan, Full scan: true) |
|         └── Serialize Result                                                                        |
|             └── Cross Apply                                                                         |
|                 ├── Scan (scan_target: $v2, scan_type: BatchScan)                                   |
|                 └── Distributed Union (call_type: Local, subquery_cluster_node: 23)                 |
|                     └── FilterScan                                                                  |
|                         └── Scan (scan_target: Songs, scan_type: TableScan)                         |
|                                                                                                        |
+--------------------------------------------------------------------------------------------------------+

It can be fixed by replacing to unambiguous width characters.
xlab/treeprint#2 (comment)

For example

func (n *Node) Render() string {
	tree := treeprint.New()
	renderTree(tree, &Link{Dest: n})
	return "\n" + strings.NewReplacer(
		"└", "+",
		"├", "+",
		"│", "|",
		"─", "-",
		).Replace(tree.String())
}
$ spanner-cli -e "EXPLAIN SELECT * FROM Songs@{FORCE_INDEX=SongsBySongName}" -t
+----------------------------------------------------------------------------------------------------+
| Query_Execution_Plan (EXPERIMENTAL)                                                                |
+----------------------------------------------------------------------------------------------------+
|                                                                                                    |
| .                                                                                                  |
| +-- Distributed Union (subquery_cluster_node: 1)                                                   |
|     +-- Distributed Cross Apply (subquery_cluster_node: 15)                                        |
|         +-- [Input]  Create Batch                                                                  |
|         |   +-- Distributed Union (call_type: Local, subquery_cluster_node: 4)                     |
|         |       +-- Compute Struct                                                                 |
|         |           +-- Scan (Full scan: true, scan_type: IndexScan, scan_target: SongsBySongName) |
|         +-- [Map]  Serialize Result                                                                |
|             +-- Cross Apply                                                                        |
|                 +-- [Input]  Scan (scan_target: $v2, scan_type: BatchScan)                         |
|                 +-- [Map]  Distributed Union (subquery_cluster_node: 23, call_type: Local)         |
|                     +-- FilterScan                                                                 |
|                         +-- Scan (scan_type: TableScan, scan_target: Songs)                        |
|                                                                                                    |
+----------------------------------------------------------------------------------------------------+
@apstndb
Copy link
Collaborator Author

apstndb commented Jun 8, 2020

Currently, EXPLAIN with table output is not important but #57 will need correct output.

@apstndb apstndb changed the title Table output EXPLAIN seems broken border because unambiguous width Table output EXPLAIN seems broken border because ambiguous width Jun 8, 2020
@yfuruyama
Copy link
Collaborator

This can't be reproduced in my terminal. What locale do you use?

This is my setting.

$ locale
LANG=""
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

@apstndb
Copy link
Collaborator Author

apstndb commented Jun 8, 2020

It would be reproduced when LC_CTYPE="ja_JP.UTF-8"

@apstndb
Copy link
Collaborator Author

apstndb commented Jun 8, 2020

@yfuruyama
Copy link
Collaborator

hmm... so there is no workaround other than replacing the character for the tree?

By the way, treepoint exposes EdgeType, so we can replace it with another character.
https://play.golang.org/p/w_07S6ByeEx

@apstndb
Copy link
Collaborator Author

apstndb commented Jun 8, 2020

I see, it seems changed in order to be customizable.
xlab/treeprint#4

It is possible to implement switching EdgeType value using locale related environment variables but it makes behavior unclear and I feel it doesn't much help users.
I prefer pure-ASCII characters tree format.

@yfuruyama
Copy link
Collaborator

+1 for using ASCII characters for tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants