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

Introduce a Literal package and provide clean utility methods for construction of literals #33

Closed
jacques-n opened this issue Jul 29, 2024 · 1 comment

Comments

@jacques-n
Copy link
Contributor

jacques-n commented Jul 29, 2024

Literals right now are a bit difficult to work with. Constructing them generally requires a bunch of sleuthing. There aren't a lot of docs and protobuf objects are leaked through the provided apis (e.g. ProtoLiteral).

Simple example. Assume we have a variable days which is an int32 of days since epoch.

Current

func NewLiteral[T allLiteralTypes](val T, nullable bool) (Literal, error)

// example usage.
expr.NewLiteral[types.Date](types.Date(days), true)

New Utility Method

func NewDate(days int) (Literal, error)

// example usage.
literal.NewDate(days)

We can also add additional methods for common conversion cases. For example, maybe we add:

NewDecimalFromTwosComplement(scale int, []byte twoscomplement)
NewDecimalFromString(str string)

etc.

As part of this we should also ensure we have reasonable test coverage for the new methods

@jacques-n
Copy link
Contributor Author

Completed in #41

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

1 participant