This repository was archived by the owner on Jan 28, 2021. It is now read-only.
sql: implement struct types #735
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #720
This PR implements struct types, which will be serialized to JSON
before being sent to the mysql client using the mysql wire proto.
Internally, structs are just
map[string]interface{}
, but they canactually be anything that's convertible to that, because of the way
the Convert method of the struct type is implemented. That means,
the result of an UDF or a table that returns a struct may be an
actual Go struct and it will then be transformed into the internal
map. It does have a penalty, though, because structs require
encoding to JSON and then decoding into
map[string]interface{}
.Structs have a schema, identical to a table schema, except their
Source
will always be empty.Resolution of columns has also been slightly change in order to
resolve getting fields from structs using the
.
operator, whichrequired some trade-offs in some rules, such as not erroring
anymore in
qualify_columns
when the table is not found. Thaterror was delegated to
resolve_columns
in order to make resolutionpossible, as the syntax is a bit ambiguous.
The advantage of using dot is the fact that no changes have to be made
to the parser in order for it to work.