-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add repeat to CREATE INDEX filter_predicate syntax #5905
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
Conversation
@davidjb : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should remain as .
BTW, the same approach is used in other similar examples, including the AND keyword page, without it being confused: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/and-transact-sql?view=sql-server-ver15
Why is it especially confusing in this one?
@davidjb : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
@pmasl The current documentation doesn't indicate that that the So, the BNF used for CREATE INDEX currently states that either 1 or 2 conditions are all that are allowed (in other words, no repeat syntax):
By comparison, a page like https://docs.microsoft.com/en-us/sql/powershell/query-expressions-and-uniform-resource-names?view=sql-server-ver15#syntax shows multiple conditions are acceptable:
My updated PR uses this latter formatting (albeit with whitespace like the other repeat syntax in this file) compared to what I had previously. As for the documentation page for AND, that covers syntax of exactly two Boolean expressions, whereas this relates to an indeterminate limit, given that my example shows that you can have as many conditions as you'd like for this type of query. A closer example is the Search Condition syntax, where an indeterminate number of AND/OR conditions can be specified:
If there are other pages where a |
@davidjb : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
@davidjb : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
#sign-off , but I’m not sure the bot’s comments are aimed at me as author vs reviewer. |
@davidjb: I'm sorry - only the author of this article, @pmasl, can sign off on your changes. But we do have an exception process - if you are on the Microsoft content or product team for this product area, you can ask the PR review team to review and merge it by sending mail to the techdocprs alias. |
@davidjb It's for the reviewer. Thanks. |
Thanks, I understand that now @ktoliver after seeing the bot’s reply. The bot’s original comment was ambiguous (“when you are finished”) — perhaps the bot could only comment when a PR is fully approved or @ mention the reviewer (since it knows who they are in the reply) or just mention it’s “for reviewers only”. Any of those would resolve the ambiguity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change @ktoliver please merge
The [current syntax](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-index-transact-sql?view=sql-server-ver15#syntax-for-sql-server-and-azure-sql-database) for CREATE INDEX's `filter_predicate` appears to imply that only one or two conditions (joined with `AND`) are supported: ``` [snip] [ WHERE <filter_predicate> ] [snip] <filter_predicate> ::= <conjunct> [ AND <conjunct> ] <conjunct> ::= <disjunct> | <comparison> [snip] ``` In other words, one `conjunct` is required and a second may optionally be provided. However, in testing with SQL Server 2019 (spun up using Docker), an arbitrary number of `conjunct`s are allowed, with a query such as this succeeding and creating the index: ```sql CREATE UNIQUE INDEX [constraint] ON [test_table] ([_type]) WHERE ([status] = 'in_progress' AND [status] IN ('needs_changes', 'published') AND [status] = 'foo' AND [status] = 'bar' AND [status] = 'baz' AND [status] IN ('more', 'disjuncts')); ``` Given the above syntax works, a `[...n]` convention needs to be added to indicate multiple conditions are acceptable (https://docs.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql?view=sql-server-ver15). This PR follows https://docs.microsoft.com/en-us/sql/t-sql/queries/search-condition-transact-sql?view=sql-server-ver15 and https://docs.microsoft.com/en-us/sql/powershell/query-expressions-and-uniform-resource-names?view=sql-server-ver15#syntax - examples in this repo's BNF syntax of multiple, optional conditions.
@davidjb : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
I've made the change made accordingly from @pmasl's feedback. |
#sign-off |
The current syntax for CREATE INDEX's
filter_predicate
appears to imply that only one or two conditions (joined withAND
) are supported:In other words, one
conjunct
is required and a second may optionally be provided. However, in testing with SQL Server 2019 (spun up using Docker), an arbitrary number ofconjunct
s are allowed, with a query such as this succeeding and creating the index:Given the above syntax works, a
[...n]
convention needs to be added toindicate multiple conditions are acceptable
(https://docs.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql?view=sql-server-ver15). This PR follows https://docs.microsoft.com/en-us/sql/powershell/query-expressions-and-uniform-resource-names?view=sql-server-ver15#syntax - the one example in this repo's BNF syntax.
Let me know if further changes are necessary.