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

Make query arguments required by default; add syntax to make them optional #1340

Closed
1st1 opened this issue Apr 13, 2020 · 3 comments
Closed

Comments

@1st1
Copy link
Member

1st1 commented Apr 13, 2020

Currently query arguments are optional but it makes more sense to make them required by default. E.g. in

SELECT <OPTIONAL int64>$0 + <int64>$1;

the $0 parameter would be optional and $1 would be required.

See also #1338 (comment)

In the context of this change we should also consider allowing use of SET OF in the argument cast, e.g.

SELECT sum(<OPTIONAL SET OF int64>$0);
# or
SELECT sum(<SET OF int64>$0);
# or
SELECT sum(<REQUIRED SET OF int64>$0);

Essentially, this all maps to the following cardinality-enforcement boundaries:

  • <int64>$arg: cardinality is 1
  • <REQUIRED int64>$arg: cardinality is 1
  • <OPTIONAL int64>$arg: cardinality is at most 1
  • <SET OF int64>$arg: cardinality is at least 0
  • <REQUIRED SET OF int64>$arg: cardinality is at least 1
  • <OPTIONAL SET OF int64>$arg: using OPTIONAL here doesn't make a lot of sense so we can prohibit this combination
@1st1
Copy link
Member Author

1st1 commented May 25, 2020

@tailhook Do we need to update the docs? Could you also clarify what specifically was implemented in the merged PR? (we'll need that in changelog, cc @vpetrovykh)

@tailhook
Copy link
Contributor

Documentation is in #1373. Shortly: by default arguments made required instead of optional and added <OPTIONAL type>$x; <REQUIRED type>$x is also supported (but no-op).

@tailhook tailhook removed their assignment Jun 1, 2020
@elprans
Copy link
Member

elprans commented Jul 20, 2020

Done.

@elprans elprans closed this as completed Jul 20, 2020
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

No branches or pull requests

3 participants