Skip to content

Conversation

@apstndb
Copy link
Collaborator

@apstndb apstndb commented Aug 1, 2024

This PR adds GRAPH(and EXPLAIN GRAPH, EXPLAIN ANALYZE GRAPH) statement support into spanner-cli.

spanner> GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id;
+-----------+----+
| label     | id |
+-----------+----+
| [Account] | 7  |
| [Account] | 16 |
| [Account] | 20 |
| [Person]  | 1  |
| [Person]  | 2  |
| [Person]  | 3  |
+-----------+----+
6 rows in set (0.81 msecs)

spanner> EXPLAIN GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id;
+-----+----------------------------------------------------------------------------------------+
| ID  | Query_Execution_Plan                                                                   |
+-----+----------------------------------------------------------------------------------------+
|   0 | Serialize Result                                                                       |
|   1 | +- Union All                                                                           |
|   2 |    +- Union Input                                                                      |
|   3 |    |  +- Distributed Union (distribution_table: Account, split_ranges_aligned: false)  |
|   4 |    |     +- Local Distributed Union                                                    |
|   5 |    |        +- Compute                                                                 |
|   6 |    |           +- Table Scan (Full scan: true, Table: Account, scan_method: Automatic) |
|  12 |    +- Union Input                                                                      |
|  13 |       +- Distributed Union (distribution_table: Person, split_ranges_aligned: false)   |
|  14 |          +- Local Distributed Union                                                    |
|  15 |             +- Compute                                                                 |
|  16 |                +- Table Scan (Full scan: true, Table: Person, scan_method: Automatic)  |
+-----+----------------------------------------------------------------------------------------+
1 rows in set (0.17 sec)

spanner> EXPLAIN ANALYZE GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id;
+-----+----------------------------------------------------------------------------------------+---------------+------------+---------------+
| ID  | Query_Execution_Plan                                                                   | Rows_Returned | Executions | Total_Latency |
+-----+----------------------------------------------------------------------------------------+---------------+------------+---------------+
|   0 | Serialize Result                                                                       | 6             | 1          | 0.14 msecs    |
|   1 | +- Union All                                                                           | 6             | 1          | 0.1 msecs     |
|   2 |    +- Union Input                                                                      |               |            |               |
|   3 |    |  +- Distributed Union (distribution_table: Account, split_ranges_aligned: false)  | 3             | 1          | 0.08 msecs    |
|   4 |    |     +- Local Distributed Union                                                    | 3             | 1          | 0.06 msecs    |
|   5 |    |        +- Compute                                                                 |               |            |               |
|   6 |    |           +- Table Scan (Full scan: true, Table: Account, scan_method: Automatic) | 3             | 1          | 0.05 msecs    |
|  12 |    +- Union Input                                                                      |               |            |               |
|  13 |       +- Distributed Union (distribution_table: Person, split_ranges_aligned: false)   | 3             | 1          | 0.02 msecs    |
|  14 |          +- Local Distributed Union                                                    | 3             | 1          | 0.01 msecs    |
|  15 |             +- Compute                                                                 |               |            |               |
|  16 |                +- Table Scan (Full scan: true, Table: Person, scan_method: Automatic)  | 3             | 1          | 0.01 msecs    |
+-----+----------------------------------------------------------------------------------------+---------------+------------+---------------+
6 rows in set (5 msecs)
timestamp:            2024-08-02T08:53:38.967843+09:00
cpu time:             4.02 msecs
rows scanned:         6 rows
deleted rows scanned: 0 rows
optimizer version:    6
optimizer statistics: auto_20240730_19_06_39UTC

fixes #180

Copy link
Collaborator

@yfuruyama yfuruyama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding this!

@yfuruyama yfuruyama merged commit a0ff8ae into cloudspannerecosystem:master Aug 2, 2024
@yfuruyama
Copy link
Collaborator

Tagged as v0.10.4

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 this pull request may close these issues.

Support Spanner Graph

2 participants