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

Consider Relaxing The Requirements for Optional and Variadic product Elements #77

Open
dlurton opened this issue Jun 7, 2021 · 0 comments

Comments

@dlurton
Copy link
Member

dlurton commented Jun 7, 2021

The Current State

PIG has the following restrictions for product elements:

  • All required elements must come first.
  • Only one of the following options may come next:
    • Any number or optional elements.
    • A single variadic element.

(Note that record types do not have the same restrictions.)

The reasons the restrictions above are historical in nature: it was to force the serialized forms of PIG type domains to be closer to the design of the V0 AST and therefore ease migration from the V0 AST to the partiql_ast PIG type domain. In the V0 AST, all optional elements were added to the end of a product instance or simply omitted to indicate that they were not present. Since the same was also true to for variadic elements, it would be impossible to differentiate between optional elements and the values of the variadic element; thus a product could not have optional and variadic elements.

The Proposed State

Since the above restrictions were first conceived we have changed the s-expression form of PIG products to use Ion's null.null to represent not-present optional product elements, which means that we can now allow required and optional elements to be specified in any order.

The above restrictions could simply be changed to:

  • There may be only one variadic element.
  • If present, the variadic element must be the last element.

If #76 was implemented, it would the be possible to remove these restrictions entirely, thereby allowing required, optional, and variadic elements to be specified in any order, without restrictions.

Backward Compatibility

We will need to do some research to see if there are other tools which require these rules to be in place--this may be a backward-incompatible change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant