diff --git a/docs/eventing-api.md b/docs/eventing-api.md index 5a4e5396b28..89aeb3a2f0e 100644 --- a/docs/eventing-api.md +++ b/docs/eventing-api.md @@ -2091,14 +2091,14 @@ expression cannot be empty strings.

-sql
+cesql
string (Optional) -

SQL is a CloudEvents SQL expression that will be evaluated to true or false against each CloudEvent.

+

CESQL is a CloudEvents SQL expression that will be evaluated to true or false against each CloudEvent.

diff --git a/pkg/apis/eventing/v1/trigger_types.go b/pkg/apis/eventing/v1/trigger_types.go index 2e15d5454aa..e327fff0e0a 100644 --- a/pkg/apis/eventing/v1/trigger_types.go +++ b/pkg/apis/eventing/v1/trigger_types.go @@ -169,10 +169,10 @@ type SubscriptionsAPIFilter struct { // +optional Suffix map[string]string `json:"suffix,omitempty"` - // SQL is a CloudEvents SQL expression that will be evaluated to true or false against each CloudEvent. + // CESQL is a CloudEvents SQL expression that will be evaluated to true or false against each CloudEvent. // // +optional - SQL string `json:"sql,omitempty"` + CESQL string `json:"cesql,omitempty"` } // TriggerFilterAttributes is a map of context attribute names to values for diff --git a/pkg/apis/eventing/v1/trigger_validation.go b/pkg/apis/eventing/v1/trigger_validation.go index ac033c1d8ba..bab5aa41f62 100644 --- a/pkg/apis/eventing/v1/trigger_validation.go +++ b/pkg/apis/eventing/v1/trigger_validation.go @@ -223,7 +223,7 @@ func ValidateSubscriptionAPIFilter(ctx context.Context, filter *SubscriptionsAPI ).Also( ValidateSubscriptionAPIFilter(ctx, filter.Not).ViaField("not"), ).Also( - ValidateCESQLExpression(ctx, filter.SQL).ViaField("sql"), + ValidateCESQLExpression(ctx, filter.CESQL).ViaField("cesql"), ) return errs } @@ -275,7 +275,7 @@ func hasMultipleDialects(filter *SubscriptionsAPIFilter) bool { dialectFound = true } } - if filter.SQL != "" && dialectFound { + if filter.CESQL != "" && dialectFound { return true } return false diff --git a/pkg/apis/eventing/v1/trigger_validation_test.go b/pkg/apis/eventing/v1/trigger_validation_test.go index 33e53e01e07..2294e8f6ccf 100644 --- a/pkg/apis/eventing/v1/trigger_validation_test.go +++ b/pkg/apis/eventing/v1/trigger_validation_test.go @@ -715,14 +715,14 @@ func TestFilterSpecValidation(t *testing.T) { name: "CE SQL with syntax error", filters: []SubscriptionsAPIFilter{ { - SQL: "this is wrong", + CESQL: "this is wrong", }}, - want: apis.ErrInvalidValue("this is wrong", "sql", "syntax error: ").ViaFieldIndex("filters", 0), + want: apis.ErrInvalidValue("this is wrong", "cesql", "syntax error: ").ViaFieldIndex("filters", 0), }, { name: "Valid CE SQL expression", filters: []SubscriptionsAPIFilter{ { - SQL: "type = 'dev.knative' AND ttl < 3", + CESQL: "type = 'dev.knative' AND ttl < 3", }}, }, } diff --git a/pkg/broker/filter/filter_handler.go b/pkg/broker/filter/filter_handler.go index b90e8546388..62a37ed754b 100644 --- a/pkg/broker/filter/filter_handler.go +++ b/pkg/broker/filter/filter_handler.go @@ -392,10 +392,10 @@ func materializeSubscriptionsAPIFilter(ctx context.Context, filter eventingv1.Su materializedFilter = subscriptionsapi.NewAnyFilter(materializeFiltersList(ctx, filter.Any)...) case filter.Not != nil: materializedFilter = subscriptionsapi.NewNotFilter(materializeSubscriptionsAPIFilter(ctx, *filter.Not)) - case filter.SQL != "": - if materializedFilter, err = subscriptionsapi.NewCESQLFilter(filter.SQL); err != nil { + case filter.CESQL != "": + if materializedFilter, err = subscriptionsapi.NewCESQLFilter(filter.CESQL); err != nil { // This is weird, CESQL expression should be validated when Trigger's are created. - logging.FromContext(ctx).Debugw("Found an Invalid CE SQL expression", zap.String("expression", filter.SQL)) + logging.FromContext(ctx).Debugw("Found an Invalid CE SQL expression", zap.String("expression", filter.CESQL)) return nil } } diff --git a/pkg/broker/filter/filter_handler_test.go b/pkg/broker/filter/filter_handler_test.go index 2a63514ecf5..f05bd82c197 100644 --- a/pkg/broker/filter/filter_handler_test.go +++ b/pkg/broker/filter/filter_handler_test.go @@ -563,7 +563,7 @@ func TestReceiver_WithSubscriptionsAPI(t *testing.T) { "Dispatch succeeded - Source with type": { triggers: []*eventingv1.Trigger{ makeTrigger(withSubscriptionAPIFilter(&eventingv1.SubscriptionsAPIFilter{ - SQL: fmt.Sprintf("type = '%s' AND source = '%s'", eventType, eventSource), + CESQL: fmt.Sprintf("type = '%s' AND source = '%s'", eventType, eventSource), })), }, expectedDispatch: true, @@ -574,7 +574,7 @@ func TestReceiver_WithSubscriptionsAPI(t *testing.T) { triggers: []*eventingv1.Trigger{ makeTrigger( withSubscriptionAPIFilter(&eventingv1.SubscriptionsAPIFilter{ - SQL: fmt.Sprintf("type = '%s' AND source = '%s'", eventType, eventSource), + CESQL: fmt.Sprintf("type = '%s' AND source = '%s'", eventType, eventSource), }), withAttributesFilter(&eventingv1.TriggerFilter{ Attributes: map[string]string{"type": "some-other-type", "source": "some-other-source"}, diff --git a/test/experimental/features/new_trigger_filters/filters.go b/test/experimental/features/new_trigger_filters/filters.go index d60123327fc..6e6176415f0 100644 --- a/test/experimental/features/new_trigger_filters/filters.go +++ b/test/experimental/features/new_trigger_filters/filters.go @@ -34,7 +34,7 @@ import ( // FiltersFeatureSet creates a feature set for testing the broker implementation of the new trigger filters experimental feature // (aka Cloud Events Subscriptions API filters). It requires a created and ready Broker resource with brokerName. // -// The feature set tests four filter dialects: exact, prefix, suffix and sql (aka CloudEvents SQL). +// The feature set tests four filter dialects: exact, prefix, suffix and cesql (aka CloudEvents SQL). func FiltersFeatureSet(brokerName string) *feature.FeatureSet { matchedEvent := FullEvent() unmatchedEvent := MinEvent() @@ -56,7 +56,7 @@ func FiltersFeatureSet(brokerName string) *feature.FeatureSet { filters: fmt.Sprintf(snippetFor("suffix"), matchedEvent.Type()[5:], matchedEvent.Source()[5:]), }, "CloudEvents SQL filter": { - filters: fmt.Sprintf(`- sql: "type = '%s' AND source = '%s'" `, matchedEvent.Type(), matchedEvent.Source()), + filters: fmt.Sprintf(`- cesql: "type = '%s' AND source = '%s'" `, matchedEvent.Type(), matchedEvent.Source()), }, }