Skip to content

Commit

Permalink
Add ShowSpaces for SessionPool
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins committed Feb 2, 2024
1 parent 0b7a337 commit 8033963
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions session_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ func (pool *SessionPool) ExecuteAndCheck(q string) (*ResultSet, error) {
return rs, nil
}

func (pool *SessionPool) ShowSpaces() ([]LabelName, error) {
rs, err := pool.ExecuteAndCheck("SHOW SPACES;")
if err != nil {
return nil, err
}

var names []LabelName
rs.Scan(&names)

return names, nil
}

func (pool *SessionPool) ShowTags() ([]LabelName, error) {
rs, err := pool.ExecuteAndCheck("SHOW TAGS;")
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions session_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ func TestSessionPoolApplySchema(t *testing.T) {
}
defer sessionPool.Close()

spaces, err := sessionPool.ShowSpaces()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 1, len(spaces), "should have 1 space")
assert.Equal(t, "test_space_schema", spaces[0].Name, "space name should be test_space_schema")

tagSchema := LabelSchema{
Name: "account",
Fields: []LabelFieldSchema{
Expand Down

0 comments on commit 8033963

Please sign in to comment.