hanahmily commented on code in PR #821: URL: https://github.com/apache/skywalking-banyandb/pull/821#discussion_r2453946771
########## pkg/bydbql/parser.go: ########## @@ -0,0 +1,254 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package bydbql + +import ( + "fmt" + "regexp" + "strings" + "time" + + "github.com/alecthomas/participle/v2" + "github.com/alecthomas/participle/v2/lexer" +) + +// Keywords list - single source of truth for all BydbQL keywords. +var bydbqlKeywords = []string{ + "SELECT", "SHOW", "TOP", "FROM", "STREAM", "MEASURE", "TRACE", "PROPERTY", + "IN", "ON", "STAGES", "TIME", "BETWEEN", "AND", "OR", "WHERE", "GROUP", "BY", "ORDER", + "ASC", "DESC", "LIMIT", "OFFSET", "WITH", "QUERY_TRACE", "SUM", "MEAN", + "AVG", "COUNT", "MAX", "MIN", "TAG", "FIELD", "NOT", "HAVING", "MATCH", + "AGGREGATE", "NULL", +} + +// Function keywords that can be directly followed by '('. +var functionKeywords = map[string]bool{ + "SUM": true, "MEAN": true, "AVG": true, "COUNT": true, "MAX": true, "MIN": true, + "MATCH": true, // MATCH can also be followed by '(' +} + +// Lexer and parser are initialized in init(). +var ( + bydbqlLexer lexer.Definition + particpleParser *participle.Parser[Grammar] + keywordPattern *regexp.Regexp +) + +func init() { + // Build lexer dynamically from keyword list to avoid duplication + keywordStr := strings.Join(bydbqlKeywords, "|") + bydbqlLexer = lexer.MustSimple([]lexer.SimpleRule{ + { + Name: "Keyword", + Pattern: fmt.Sprintf(`(?i)(%s)\b`, keywordStr), + }, + {Name: "Ident", Pattern: `[a-zA-Z_][a-zA-Z0-9_-]*`}, + {Name: "Int", Pattern: `[-+]?\d+`}, + {Name: "String", Pattern: `'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"`}, + {Name: "QuotedIdent", Pattern: `"[a-zA-Z_][a-zA-Z0-9_.]*"|'[a-zA-Z_][a-zA-Z0-9_.]*'`}, + {Name: "Operators", Pattern: `!=|>=|<=|::|[=><,.()*]`}, + {Name: "whitespace", Pattern: `\s+`}, + }) + + // Build parser with the dynamically created lexer + var err error + particpleParser, err = participle.Build[Grammar]( + participle.Lexer(bydbqlLexer), + participle.Unquote("String"), + participle.Unquote("QuotedIdent"), + participle.CaseInsensitive("Keyword"), + participle.UseLookahead(2), + ) + if err != nil { + panic(fmt.Sprintf("failed to build BydbQL parser: %v", err)) + } + + // Build keyword pattern for validation (reuse keywordStr to avoid duplication) + keywordPattern = regexp.MustCompile(fmt.Sprintf(`(?i)\b(%s)\b`, keywordStr)) +} + +// validateKeywordSpacing checks that all keywords in the query are properly separated by whitespace. +// Returns an error if any keyword is not preceded or followed by valid separators. +func validateKeywordSpacing(query string) error { Review Comment: I strongly recommend against using the regular expression to analyze the AST. From my experience of building a SQL engine, it would bring numeric bugs to us. For example, this function can not validate QL: `SELECT * FROM STREAM foo IN('a')` ########## pkg/bydbql/grammar.go: ########## @@ -0,0 +1,1064 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package bydbql provides BanyanDB Query Language (BydbQL) parsing and translation capabilities. +// +//nolint:govet // ignore fieldalignment in this file; layout is the bydbQL grammar +package bydbql + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/alecthomas/participle/v2/lexer" +) + +// Grammar represents the root of a BydbQL statement parsed by Participle. +type Grammar struct { + Select *GrammarSelectStatement `parser:" @@"` + TopN *GrammarTopNStatement `parser:"| @@"` +} + +// GrammarSelectStatement represents a SELECT statement in Participle grammar. +type GrammarSelectStatement struct { + Pos lexer.Position + Select string `parser:"@'SELECT'"` + Projection *GrammarProjection `parser:"@@"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarSelectWhereClause `parser:"@@?"` + GroupBy *GrammarGroupByClause `parser:"@@?"` + OrderBy *GrammarSelectOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` + Limit *GrammarLimitClause `parser:"@@?"` + Offset *GrammarOffsetClause `parser:"@@?"` +} + +// GrammarTopNStatement represents a SHOW TOP N statement. +type GrammarTopNStatement struct { + Pos lexer.Position + Show string `parser:"@'SHOW'"` + Top string `parser:"@'TOP'"` + N int `parser:"@Int"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarTopNWhereClause `parser:"@@?"` + AggregateBy *GrammarTopNAggregateByClause `parser:"@@?"` + OrderBy *GrammarTopNOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` +} + +// GrammarProjection represents projection in SELECT. +type GrammarProjection struct { + All bool `parser:" @'*'"` + Empty bool `parser:"| @'(' ')'"` + TopN *GrammarTopNProjection `parser:"| 'TOP' @@"` + Columns []*GrammarColumn `parser:"| @@ ( ',' @@ )*"` +} + +// GrammarTopNProjection represents TOP N projection. +type GrammarTopNProjection struct { + N int `parser:"@Int"` + OrderField *GrammarIdentifierPath `parser:"@@"` + Direction *string `parser:"@('ASC'|'DESC')?"` + OtherColumns []*GrammarColumn `parser:" ( ',' @@ ( ',' @@ )* )?"` +} + +// GrammarColumn represents a column in projection. +type GrammarColumn struct { + Aggregate *GrammarAggregateFunction `parser:" @@"` + Identifier *GrammarIdentifierPath `parser:"| @@"` + TypeSpec *string `parser:"( '::' @('TAG'|'FIELD') )?"` +} + +// GrammarAggregateFunction represents aggregate functions. +type GrammarAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` + Column *GrammarIdentifierPath `parser:"'(' @@ ')'"` +} + +// GrammarTopNAggregateFunction represents aggregate functions without column (for TOP N). +type GrammarTopNAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` +} + +// GrammarFromClause represents FROM clause. +type GrammarFromClause struct { + From string `parser:"@'FROM'"` + ResourceType string `parser:"@('STREAM'|'MEASURE'|'TRACE'|'PROPERTY')"` + ResourceName string `parser:"@Ident"` + In *GrammarInClause `parser:"@@"` + Stage *GrammarStageClause `parser:"@@?"` +} + +// GrammarInClause represents IN clause. +type GrammarInClause struct { + In string `parser:"@'IN'"` + LParen bool `parser:"@'('?"` + Groups []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` +} + +// GrammarStageClause represents STAGES clause. +type GrammarStageClause struct { + On string `parser:"@'ON'"` + LParen bool `parser:"@'('?"` + Stages []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` + Stages2 string `parser:"@'STAGES'"` +} + +// GrammarTimeClause represents TIME clause. +type GrammarTimeClause struct { + Time string `parser:"@'TIME'"` + Comparator *string `parser:"( @( '=' | '>' | '<' | '>=' | '<=' )"` + Value *GrammarTimeValue `parser:" @@"` + Between *GrammarTimeBetween `parser:"| @@ )"` +} + +// GrammarTimeBetween represents TIME BETWEEN. +type GrammarTimeBetween struct { + Between string `parser:"@'BETWEEN'"` + Begin *GrammarTimeValue `parser:"@@"` + And string `parser:"@'AND'"` + End *GrammarTimeValue `parser:"@@"` +} + +// GrammarTimeValue represents a time value (string or integer). +type GrammarTimeValue struct { + String *string `parser:" @String"` + Integer *int64 `parser:"| @Int"` +} + +// GrammarSelectWhereClause represents WHERE clause. +type GrammarSelectWhereClause struct { + Where string `parser:"@'WHERE'"` + Expr *GrammarOrExpr `parser:"@@"` +} + +// GrammarTopNWhereClause represents WHERE clause in TOP N. +type GrammarTopNWhereClause struct { + Where string `parser:"@'WHERE'"` + Expr *GrammarAndExpr `parser:"@@"` Review Comment: Only simple equality is supported ########## pkg/bydbql/grammar.go: ########## @@ -0,0 +1,1064 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package bydbql provides BanyanDB Query Language (BydbQL) parsing and translation capabilities. +// +//nolint:govet // ignore fieldalignment in this file; layout is the bydbQL grammar +package bydbql + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/alecthomas/participle/v2/lexer" +) + +// Grammar represents the root of a BydbQL statement parsed by Participle. +type Grammar struct { + Select *GrammarSelectStatement `parser:" @@"` + TopN *GrammarTopNStatement `parser:"| @@"` +} + +// GrammarSelectStatement represents a SELECT statement in Participle grammar. +type GrammarSelectStatement struct { + Pos lexer.Position + Select string `parser:"@'SELECT'"` + Projection *GrammarProjection `parser:"@@"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarSelectWhereClause `parser:"@@?"` + GroupBy *GrammarGroupByClause `parser:"@@?"` + OrderBy *GrammarSelectOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` + Limit *GrammarLimitClause `parser:"@@?"` + Offset *GrammarOffsetClause `parser:"@@?"` +} + +// GrammarTopNStatement represents a SHOW TOP N statement. +type GrammarTopNStatement struct { + Pos lexer.Position + Show string `parser:"@'SHOW'"` + Top string `parser:"@'TOP'"` + N int `parser:"@Int"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarTopNWhereClause `parser:"@@?"` + AggregateBy *GrammarTopNAggregateByClause `parser:"@@?"` + OrderBy *GrammarTopNOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` +} + +// GrammarProjection represents projection in SELECT. +type GrammarProjection struct { + All bool `parser:" @'*'"` + Empty bool `parser:"| @'(' ')'"` + TopN *GrammarTopNProjection `parser:"| 'TOP' @@"` + Columns []*GrammarColumn `parser:"| @@ ( ',' @@ )*"` +} + +// GrammarTopNProjection represents TOP N projection. +type GrammarTopNProjection struct { + N int `parser:"@Int"` + OrderField *GrammarIdentifierPath `parser:"@@"` + Direction *string `parser:"@('ASC'|'DESC')?"` + OtherColumns []*GrammarColumn `parser:" ( ',' @@ ( ',' @@ )* )?"` +} + +// GrammarColumn represents a column in projection. +type GrammarColumn struct { + Aggregate *GrammarAggregateFunction `parser:" @@"` + Identifier *GrammarIdentifierPath `parser:"| @@"` + TypeSpec *string `parser:"( '::' @('TAG'|'FIELD') )?"` +} + +// GrammarAggregateFunction represents aggregate functions. +type GrammarAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` + Column *GrammarIdentifierPath `parser:"'(' @@ ')'"` +} + +// GrammarTopNAggregateFunction represents aggregate functions without column (for TOP N). +type GrammarTopNAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` +} + +// GrammarFromClause represents FROM clause. +type GrammarFromClause struct { + From string `parser:"@'FROM'"` + ResourceType string `parser:"@('STREAM'|'MEASURE'|'TRACE'|'PROPERTY')"` + ResourceName string `parser:"@Ident"` + In *GrammarInClause `parser:"@@"` + Stage *GrammarStageClause `parser:"@@?"` +} + +// GrammarInClause represents IN clause. +type GrammarInClause struct { + In string `parser:"@'IN'"` + LParen bool `parser:"@'('?"` + Groups []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` +} + +// GrammarStageClause represents STAGES clause. +type GrammarStageClause struct { + On string `parser:"@'ON'"` + LParen bool `parser:"@'('?"` + Stages []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` + Stages2 string `parser:"@'STAGES'"` +} + +// GrammarTimeClause represents TIME clause. +type GrammarTimeClause struct { + Time string `parser:"@'TIME'"` + Comparator *string `parser:"( @( '=' | '>' | '<' | '>=' | '<=' )"` + Value *GrammarTimeValue `parser:" @@"` + Between *GrammarTimeBetween `parser:"| @@ )"` +} + +// GrammarTimeBetween represents TIME BETWEEN. +type GrammarTimeBetween struct { + Between string `parser:"@'BETWEEN'"` + Begin *GrammarTimeValue `parser:"@@"` + And string `parser:"@'AND'"` + End *GrammarTimeValue `parser:"@@"` +} + +// GrammarTimeValue represents a time value (string or integer). +type GrammarTimeValue struct { + String *string `parser:" @String"` + Integer *int64 `parser:"| @Int"` +} + +// GrammarSelectWhereClause represents WHERE clause. +type GrammarSelectWhereClause struct { + Where string `parser:"@'WHERE'"` + Expr *GrammarOrExpr `parser:"@@"` +} + +// GrammarTopNWhereClause represents WHERE clause in TOP N. +type GrammarTopNWhereClause struct { + Where string `parser:"@'WHERE'"` + Expr *GrammarAndExpr `parser:"@@"` +} + +// GrammarOrExpr represents OR expression. +type GrammarOrExpr struct { + Left *GrammarAndExpr `parser:"@@"` + Right []*GrammarOrRight `parser:"@@*"` +} + +// GrammarOrRight represents right side of OR. +type GrammarOrRight struct { + Or string `parser:"@'OR'"` + Right *GrammarAndExpr `parser:"@@"` +} + +// GrammarAndExpr represents AND expression. +type GrammarAndExpr struct { Review Comment: TopN is the AND only. It can restrict: "WHERE (status = 200 OR status = 404)" ########## pkg/bydbql/grammar.go: ########## @@ -0,0 +1,1064 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package bydbql provides BanyanDB Query Language (BydbQL) parsing and translation capabilities. +// +//nolint:govet // ignore fieldalignment in this file; layout is the bydbQL grammar +package bydbql + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/alecthomas/participle/v2/lexer" +) + +// Grammar represents the root of a BydbQL statement parsed by Participle. +type Grammar struct { + Select *GrammarSelectStatement `parser:" @@"` + TopN *GrammarTopNStatement `parser:"| @@"` +} + +// GrammarSelectStatement represents a SELECT statement in Participle grammar. +type GrammarSelectStatement struct { + Pos lexer.Position + Select string `parser:"@'SELECT'"` + Projection *GrammarProjection `parser:"@@"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` Review Comment: TIME is mandatory for stream, measure and trace. ########## pkg/bydbql/grammar.go: ########## @@ -0,0 +1,1064 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package bydbql provides BanyanDB Query Language (BydbQL) parsing and translation capabilities. +// +//nolint:govet // ignore fieldalignment in this file; layout is the bydbQL grammar +package bydbql + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/alecthomas/participle/v2/lexer" +) + +// Grammar represents the root of a BydbQL statement parsed by Participle. +type Grammar struct { + Select *GrammarSelectStatement `parser:" @@"` + TopN *GrammarTopNStatement `parser:"| @@"` +} + +// GrammarSelectStatement represents a SELECT statement in Participle grammar. +type GrammarSelectStatement struct { + Pos lexer.Position + Select string `parser:"@'SELECT'"` + Projection *GrammarProjection `parser:"@@"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarSelectWhereClause `parser:"@@?"` + GroupBy *GrammarGroupByClause `parser:"@@?"` + OrderBy *GrammarSelectOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` + Limit *GrammarLimitClause `parser:"@@?"` + Offset *GrammarOffsetClause `parser:"@@?"` +} + +// GrammarTopNStatement represents a SHOW TOP N statement. +type GrammarTopNStatement struct { + Pos lexer.Position + Show string `parser:"@'SHOW'"` + Top string `parser:"@'TOP'"` + N int `parser:"@Int"` + From *GrammarFromClause `parser:"@@"` + Time *GrammarTimeClause `parser:"@@?"` + Where *GrammarTopNWhereClause `parser:"@@?"` + AggregateBy *GrammarTopNAggregateByClause `parser:"@@?"` + OrderBy *GrammarTopNOrderByClause `parser:"@@?"` + WithQueryTrace *GrammarWithTraceClause `parser:"@@?"` +} + +// GrammarProjection represents projection in SELECT. +type GrammarProjection struct { + All bool `parser:" @'*'"` + Empty bool `parser:"| @'(' ')'"` + TopN *GrammarTopNProjection `parser:"| 'TOP' @@"` + Columns []*GrammarColumn `parser:"| @@ ( ',' @@ )*"` +} + +// GrammarTopNProjection represents TOP N projection. +type GrammarTopNProjection struct { + N int `parser:"@Int"` + OrderField *GrammarIdentifierPath `parser:"@@"` + Direction *string `parser:"@('ASC'|'DESC')?"` + OtherColumns []*GrammarColumn `parser:" ( ',' @@ ( ',' @@ )* )?"` +} + +// GrammarColumn represents a column in projection. +type GrammarColumn struct { + Aggregate *GrammarAggregateFunction `parser:" @@"` + Identifier *GrammarIdentifierPath `parser:"| @@"` + TypeSpec *string `parser:"( '::' @('TAG'|'FIELD') )?"` +} + +// GrammarAggregateFunction represents aggregate functions. +type GrammarAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` + Column *GrammarIdentifierPath `parser:"'(' @@ ')'"` +} + +// GrammarTopNAggregateFunction represents aggregate functions without column (for TOP N). +type GrammarTopNAggregateFunction struct { + Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"` +} + +// GrammarFromClause represents FROM clause. +type GrammarFromClause struct { + From string `parser:"@'FROM'"` + ResourceType string `parser:"@('STREAM'|'MEASURE'|'TRACE'|'PROPERTY')"` + ResourceName string `parser:"@Ident"` + In *GrammarInClause `parser:"@@"` + Stage *GrammarStageClause `parser:"@@?"` +} + +// GrammarInClause represents IN clause. +type GrammarInClause struct { + In string `parser:"@'IN'"` + LParen bool `parser:"@'('?"` + Groups []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` +} + +// GrammarStageClause represents STAGES clause. +type GrammarStageClause struct { + On string `parser:"@'ON'"` + LParen bool `parser:"@'('?"` + Stages []string `parser:"@Ident ( ',' @Ident )*"` + RParen bool `parser:"@')'?"` + Stages2 string `parser:"@'STAGES'"` +} + +// GrammarTimeClause represents TIME clause. +type GrammarTimeClause struct { + Time string `parser:"@'TIME'"` + Comparator *string `parser:"( @( '=' | '>' | '<' | '>=' | '<=' )"` + Value *GrammarTimeValue `parser:" @@"` + Between *GrammarTimeBetween `parser:"| @@ )"` +} + +// GrammarTimeBetween represents TIME BETWEEN. +type GrammarTimeBetween struct { + Between string `parser:"@'BETWEEN'"` + Begin *GrammarTimeValue `parser:"@@"` + And string `parser:"@'AND'"` + End *GrammarTimeValue `parser:"@@"` +} + +// GrammarTimeValue represents a time value (string or integer). +type GrammarTimeValue struct { + String *string `parser:" @String"` + Integer *int64 `parser:"| @Int"` +} + +// GrammarSelectWhereClause represents WHERE clause. +type GrammarSelectWhereClause struct { + Where string `parser:"@'WHERE'"` + Expr *GrammarOrExpr `parser:"@@"` Review Comment: property only support: "=" | "!=" | ">" | "<" | ">=" | "<=" | "IN" | "NOT IN" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
