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

Implement RelTypes module for user- and system-defined (de)serialization hooks #77

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bachdavi
Copy link
Member

@bachdavi bachdavi commented Sep 25, 2022

This PR adds a RelTypes module that exports two methods: JuliaType and from_rel. These can be used to register type conversions from Rel ValueTypes to native Julia types. Currently only from Rel and not to Rel is supported. Conversion does not happen eagerly but rather on read-time. Currently, only show_result will show the converted types.

To register a conversion, we have to create an overload of the JuliaType method. It takes three parameters:

  • A Val containing the markers of the value type, such as (:MyInt,), or (:MyType, :foo, :bar). The first element is always the Rel name of the value type.
  • A type describing the field types this ValueType has, such as Tuple{Int64,Int64} in the case of value type MyInt = Int, Int. It's either a single type or a tuple type.
  • [Optional] A vector of parameters. A parameter is a non-symbol constant type in the signature. Such as value type MyInt = #(1), Int, Int.

Here is an example:

value type Point = Int, Int
struct Point
    x::Int64
    y::Int64
end
JuliaType(::Val{(:Point,)}, Tuple{Int64,Int64} = Point
from_rel(::Type{Point}, t) = Point(t...)

There are a few things left:

  • Tests
  • Finish system-defined ValueTypes.
  • Fix hard-coded Column creation in results.jl
  • Properly convert specialized types and values as well, currently, we only convert the types

@bachdavi bachdavi requested review from NHDaly and quinnj September 26, 2022 06:41
@bachdavi
Copy link
Member Author

@NHDaly and @quinnj Adding you as reviewers :)
It's heavily inspired by ArrowTypes ;)

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

Successfully merging this pull request may close these issues.

2 participants