Change Wild to Wildcard and move test
parent
f8073bf287
commit
26ecd06ef5
|
@ -47,7 +47,7 @@ func (_ *TimeLiteral) node() {}
|
||||||
func (_ *DurationLiteral) node() {}
|
func (_ *DurationLiteral) node() {}
|
||||||
func (_ *BinaryExpr) node() {}
|
func (_ *BinaryExpr) node() {}
|
||||||
func (_ *ParenExpr) node() {}
|
func (_ *ParenExpr) node() {}
|
||||||
func (_ *Wild) node() {}
|
func (_ *Wildcard) node() {}
|
||||||
|
|
||||||
// Query represents a collection of order statements.
|
// Query represents a collection of order statements.
|
||||||
type Query struct {
|
type Query struct {
|
||||||
|
@ -86,7 +86,7 @@ func (_ *TimeLiteral) expr() {}
|
||||||
func (_ *DurationLiteral) expr() {}
|
func (_ *DurationLiteral) expr() {}
|
||||||
func (_ *BinaryExpr) expr() {}
|
func (_ *BinaryExpr) expr() {}
|
||||||
func (_ *ParenExpr) expr() {}
|
func (_ *ParenExpr) expr() {}
|
||||||
func (_ *Wild) expr() {}
|
func (_ *Wildcard) expr() {}
|
||||||
|
|
||||||
// Source represents a source of data for a statement.
|
// Source represents a source of data for a statement.
|
||||||
type Source interface {
|
type Source interface {
|
||||||
|
@ -236,9 +236,8 @@ type ParenExpr struct {
|
||||||
Expr Expr
|
Expr Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wild represents a wild card expression.
|
// Wildcard represents a wild card expression.
|
||||||
type Wild struct {
|
type Wildcard struct {
|
||||||
Val string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visitor can be called by Walk to traverse an AST hierarchy.
|
// Visitor can be called by Walk to traverse an AST hierarchy.
|
||||||
|
|
|
@ -265,7 +265,7 @@ func (p *Parser) parseFields() (Fields, error) {
|
||||||
|
|
||||||
// Check for "*" (i.e., "all fields")
|
// Check for "*" (i.e., "all fields")
|
||||||
if tok, _, _ := p.scanIgnoreWhitespace(); tok == MUL {
|
if tok, _, _ := p.scanIgnoreWhitespace(); tok == MUL {
|
||||||
fields = append(fields, &Field{&Wild{"*"}, ""})
|
fields = append(fields, &Field{&Wildcard{}, ""})
|
||||||
return fields, nil
|
return fields, nil
|
||||||
}
|
}
|
||||||
p.unscan()
|
p.unscan()
|
||||||
|
|
|
@ -9,17 +9,6 @@ import (
|
||||||
"github.com/influxdb/influxdb/influxql"
|
"github.com/influxdb/influxdb/influxql"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure the parser can parse a SELECT * query.
|
|
||||||
func TestParser_ParseQuery_SelectStar(t *testing.T) {
|
|
||||||
s := `SELECT * FROM b; SELECT c FROM d`
|
|
||||||
q, err := influxql.NewParser(strings.NewReader(s)).ParseQuery()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %s", err)
|
|
||||||
} else if len(q.Statements) != 2 {
|
|
||||||
t.Fatalf("unexpected statement count: %d", len(q.Statements))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the parser can parse a multi-statement query.
|
// Ensure the parser can parse a multi-statement query.
|
||||||
func TestParser_ParseQuery(t *testing.T) {
|
func TestParser_ParseQuery(t *testing.T) {
|
||||||
s := `SELECT a FROM b; SELECT c FROM d`
|
s := `SELECT a FROM b; SELECT c FROM d`
|
||||||
|
@ -56,6 +45,17 @@ func TestParser_ParseStatement(t *testing.T) {
|
||||||
stmt influxql.Statement
|
stmt influxql.Statement
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
|
// SELECT * statement
|
||||||
|
{
|
||||||
|
s: `SELECT * FROM myseries`,
|
||||||
|
stmt: &influxql.SelectStatement{
|
||||||
|
Fields: influxql.Fields{
|
||||||
|
&influxql.Field{Expr: &influxql.Wildcard{}},
|
||||||
|
},
|
||||||
|
Source: &influxql.Series{Name: "myseries"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// SELECT statement
|
// SELECT statement
|
||||||
{
|
{
|
||||||
s: `SELECT field1, field2 ,field3 AS field_x FROM myseries WHERE host = 'hosta.influxdb.org' GROUP BY 10h LIMIT 20 ORDER BY ASC;`,
|
s: `SELECT field1, field2 ,field3 AS field_x FROM myseries WHERE host = 'hosta.influxdb.org' GROUP BY 10h LIMIT 20 ORDER BY ASC;`,
|
||||||
|
|
Loading…
Reference in New Issue