Skip to content

Commit a0ff8ae

Browse files
authored
Support GRAPH statement (#181)
1 parent 9a93cfa commit a0ff8ae

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

statement.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type QueryStats struct {
8282

8383
var (
8484
// SQL
85-
selectRe = regexp.MustCompile(`(?is)^(?:WITH|CALL|@{.+|SELECT)\s.+$`)
85+
selectRe = regexp.MustCompile(`(?is)^(?:WITH|CALL|@{.+|SELECT|GRAPH)\s.+$`)
8686

8787
// DDL
8888
createDatabaseRe = regexp.MustCompile(`(?is)^CREATE\s+DATABASE\s.+$`)

statement_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,21 @@ func TestBuildStatement(t *testing.T) {
507507
input: "EXPLAIN WITH t1 AS (SELECT 1) SELECT * FROM t1",
508508
want: &ExplainStatement{Explain: "WITH t1 AS (SELECT 1) SELECT * FROM t1"},
509509
},
510+
{
511+
desc: "GRAPH statement",
512+
input: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id",
513+
want: &SelectStatement{Query: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"},
514+
},
515+
{
516+
desc: "EXPLAIN GRAPH statement",
517+
input: "EXPLAIN GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id",
518+
want: &ExplainStatement{Explain: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"},
519+
},
520+
{
521+
desc: "EXPLAIN ANALYZE GRAPH statement",
522+
input: "EXPLAIN ANALYZE GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id",
523+
want: &ExplainAnalyzeStatement{Query: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"},
524+
},
510525
{
511526
desc: "DESCRIBE SELECT statement",
512527
input: "DESCRIBE SELECT * FROM t1",

0 commit comments

Comments
 (0)