Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrInvalidFilter ¶ added in v1.4.2
type ErrInvalidFilter struct {
// contains filtered or unexported fields
}
func (ErrInvalidFilter) Error ¶ added in v1.4.2
func (e ErrInvalidFilter) Error() string
func (ErrInvalidFilter) GRPCStatus ¶ added in v1.4.3
func (e ErrInvalidFilter) GRPCStatus() *status.Status
func (ErrInvalidFilter) Is ¶ added in v1.4.2
func (e ErrInvalidFilter) Is(target error) bool
type ErrInvalidIdentifier ¶ added in v1.4.2
type ErrInvalidIdentifier struct {
// contains filtered or unexported fields
}
func (ErrInvalidIdentifier) Error ¶ added in v1.4.2
func (e ErrInvalidIdentifier) Error() string
func (ErrInvalidIdentifier) GRPCStatus ¶ added in v1.4.3
func (e ErrInvalidIdentifier) GRPCStatus() *status.Status
func (ErrInvalidIdentifier) Is ¶ added in v1.4.2
func (e ErrInvalidIdentifier) Is(target error) bool
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a CEL filter expression to Spanner query parser.
It is used to parse a CEL filter expression and convert it to a Spanner statement.
func NewFilter ¶
func NewFilter(identifiers ...Identifier) (*Filter, error)
NewFilter creates a new Filter instance with the given identifiers.
Identifiers are used to declare common protocol buffer types for conversion. Common identifiers are Timestamp, Duration, Date etc.
func (*Filter) DeclareIdentifier ¶
func (f *Filter) DeclareIdentifier(identifier Identifier) error
DeclareIdentifier declares a new Identifier in the environment.
This is useful when you want to add a new identifier to the environment after creating the Filter instance.
May return an ErrInvalidIdentifier error if the identifier is invalid.
func (*Filter) Parse ¶
Parse parses a CEL filter expression and returns a Spanner statement.
Examples:
filter.Parse("Proto.effective_date.year > 2021 AND create_time > timestamp('2021-01-01T00:00:00Z') OR expire_after > duration('1h')") filter.Parse("key = 'resources/1' OR Proto.effective_date = date('2021-01-01')") filter.Parse("Proto.state = 'ACTIVE'" filter.Parse("key IN ['resources/1', 'resources/2']") filter.Parse("effective_date != null) filter.Parse("count >= 10)
May return an ErrInvalidFilter error if the filter is invalid.
type Identifier ¶
type Identifier interface { Path() string // contains filtered or unexported methods }
Identifier represents a CEL type identifier for certain types.
Commonly used for identifying and transforming protocol buffer types. For example:
- Timestamp() will convert a google.protobuf.Timestamp to a spanner Timestamp type.
- Duration() will convert a google.protobuf.Duration to a spanner String type.
func Date ¶
func Date(path string) Identifier
Date enables conversion of google.type.Date to a spanner String/Date type.
It takes in the path to the column/field.
Example:
Date("effective_date") Date("Proto.effective_date")
func Duration ¶
func Duration(path string) Identifier
Duration enables conversion of google.protobuf.Duration to a spanner int type.
It takes in the path to the column/field.
Example:
Duration("expire_after") Duration("Proto.expire_after")
func Reserved ¶ added in v1.4.6
func Reserved(name string) Identifier
Reserved allows for the querying of columns with reserved keywords. It instructs the parser to wrap the column names with backticks(`). This is only required if you have a column with a reserved keyword
It takes in the name of the column.
func Timestamp ¶
func Timestamp(path string) Identifier
Timestamp enables conversion of google.protobuf.Timestamp to a spanner String/Timestamp type.
It takes in the path to the column/field.
Example:
Timestamp("create_time") Timestamp("Proto.create_time")