Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand tck tests #1227

Merged
merged 4 commits into from
Sep 28, 2023
Merged

Expand tck tests #1227

merged 4 commits into from
Sep 28, 2023

Conversation

Cali0707
Copy link
Contributor

Fixes #1225

Proposed Changes

  • Add tck test cases which verify that the "LIKE" operator works when the operand is not a string and needs to be coerced to string
  • Add tck test cases for suffix, prefix, and exact filter implementations
  • Add tck test cases for ANDs and ORs of suffix, prefix, and exact filter implementations

Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Contributor Author

cc @duglin @pierDipi

result: false

- name: With type coercion from bool (1)
expression: "TRUE LIKE 'tr%'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does the spec say "TRUE" is a bool? I only see "true"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I wasn't referring to the spec here, rather the existing tck tests:

- name: Cast identity TRUE
expression: BOOL(TRUE)
result: true
- name: Cast identity FALSE
expression: BOOL(FALSE)
result: FALSE

Do you think I should switch this to true here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be in a better position than me since my only knowledge of the spec is based on this PR and my current reading of the spec to review your PR ;-) , but is the "expression" string meant to adhere to the syntax defined by the spec? If so, then it seems like it may need to be true or the spec needs to allow for both upper and lower case bools. Actually, the spec should probably say which things are case sensitive or not, in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duglin from https://github.com/cloudevents/spec/blob/main/cesql/spec.md#2-language-syntax it looks like the grammar is case-insensitive so both true and TRUE should be valid. Maybe we can open a new issue to add clarification to the spec where we mention the boolean literals that this is the case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be good since it may not be clear that "keywords" don't just mean function names, or operators, but also constants. And thanks for the pointer - I missed that.

source: "http://www.some-website.com"
- name: Prefix OR Suffix filter (5)
expression: "id LIKE 'my%' OR myext LIKE '%ext'"
error: missingAttribute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, does the spec say that the stuff after the OR must be evaluated if the first part evaluates to 'true'? We should add a test for that, unless I missed it. In particular, if the 2nd part would generate an error if evaluated... what should happen if someone chooses to NOT evaluate it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, what I could find was:

Because every operator and function is total, an expression evaluation flow is defined statically and cannot be modified by expected or unexpected errors. Nevertheless CESQL includes the concept of errors: when an expression is evaluated, in case an error arises, the evaluator collects a list of errors, referred in this spec as error list, which is then returned together with the evaluated value of the CESQL expression.

So, I guess the spec does not explicitly specify whether or not there should be an error if the OR has an early return. Do you think we should specify this?

Copy link
Collaborator

@duglin duglin Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sure does seem like the spec should be clear on what true OR error results in... either true or error. Otherwise we'll have an interop issue. I would think most people would expect true but I'm not an expert in what query languages normally do for this. @lionelvillard @embano1 any thoughts?

Copy link
Contributor Author

@Cali0707 Cali0707 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duglin on the go sdk v2, when evaluating (type = 'dev.knative.example') OR (missingattribute = 'test') on an event with type: 'dev.knative.example' but no missingattribute I get: missing attribute 'missingattribute'

So, it seems like the current behaviour (at least for go) is that it reports the error, even if the first part evaluated to true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I open an issue to clarify this behaviour, or do we want to open an issue to change this behaviour and make it behave like you think most people would expect (true instead of error)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like from https://github.com/cloudevents/spec/blob/main/cesql/spec.md#41-error-handling that we would always return the error regardless of the result though (either fail fast, or continue and find the result and then return result and error)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should open an issue to get feedback from the group and then make it clear in the spec... and then align the go-sdk if needed.

source: "http://www.some-website.com"

- name: Disjunctive Normal Form (1)
expresion: "(id = 'myId' AND type LIKE '%.success') OR (id = 'notmyId' AND source LIKE 'http://%' AND type LIKE '%.warning')"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might answer my previous question :-) but where is that in the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, don't think that this is in the spec - I guess we should clarify whether or not this is an error that would occur, or whether it would be implementation specific

type: "example.event.warning"
- name: Conjunctive Normal Form (4)
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning')"
result: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this generate an error due to missing 'source' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep my bad, I forgot that source was not set by default in these test - I'll fix it!

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707 Cali0707 requested a review from duglin September 21, 2023 19:38
@duglin
Copy link
Collaborator

duglin commented Sep 26, 2023

@Cali0707 is this one ready to be merged? I assume so, and we have the follow-on issues to continue to clarifying questions. Right?

@Cali0707
Copy link
Contributor Author

@Cali0707 is this one ready to be merged? I assume so, and we have the follow-on issues to continue to clarifying questions. Right?

@duglin I think if we want to merge this now, I should remove the tests which may or may not error on a OR, otherwise we might break tests on some of the SDKs depending on their implementation since that isn't specified currently.

@duglin
Copy link
Collaborator

duglin commented Sep 26, 2023

ok sounds good. Let me know when done and then we can vote on it during the Thursday call

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Contributor Author

@duglin I believe I have removed the two tests with issues in them. If you think this is ready, then I think it is ready to be voted on on Thursday. Thanks for all of your help on this!

@duglin duglin merged commit a04f46e into cloudevents:main Sep 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand the CESQL tck tests
2 participants