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

Arrow: Add tstype to arrow metadata #580

Merged
merged 7 commits into from Dec 14, 2022

Conversation

ryantxu
Copy link
Member

@ryantxu ryantxu commented Dec 13, 2022

We are looking for ways to support some new field types -- specifically an "enum" type that has a native mapping from number<>string+metadata.

With the existing approach of 1:1, arrow type <-> go type, this is not possible, we would require additional metadata to make the shift.

This PR introduces an additional metadata property to arrow that matches the typescript type used in the frontend. We can then use that type help pick which type to create

@ryantxu ryantxu requested a review from a team as a code owner December 13, 2022 18:46
@ryantxu ryantxu requested review from wbrowne, marefr, kylebrandt and toddtreece and removed request for a team, wbrowne and marefr December 13, 2022 18:46
data/arrow.go Outdated Show resolved Hide resolved
data/field.go Outdated
@@ -38,15 +39,24 @@ type Fields []*Field
// NewField returns a instance of *Field. Supported types for values are:
//
// Integers:
// []int8, []*int8, []int16, []*int16, []int32, []*int32, []int64, []*int64
//
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an effort to keep the "real" PR smaller and more legible, this is batching all the auto-formatting updates into this PR 😬

@kylebrandt
Copy link
Contributor

I really like this idea to move forward with new field types. Would feel better if there is an additional Go Field type so we know the end to end typing mapping isn't going to hit some snag (perhaps another PR based off this one?).

@ryantxu
Copy link
Member Author

ryantxu commented Dec 13, 2022

(perhaps another PR based off this one?).

😄 #581 -- WIP, but wanted to keep this basic infra change independent

@@ -86,11 +93,13 @@ func buildArrowFields(f *Frame) ([]arrow.Field, error) {
if err != nil {
return nil, err
}

fieldMeta := map[string]string{"name": field.Name}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ the "name" field was redundant, and never used!

@@ -74,8 +74,8 @@
{ "name": "timestamps", "type": "time", "typeInfo": { "frame": "time.Time" }, "config": { "interval": 1000 } },
{ "name": "timestamps", "type": "time", "typeInfo": { "frame": "time.Time" } },
{ "name": "nullable_timestamps", "type": "time", "typeInfo": { "frame": "time.Time", "nullable": true } },
{ "name": "json", "type":"other", "typeInfo": { "frame": "json.RawMessage" } },
{ "name": "nullable_json", "type":"other", "typeInfo": { "frame": "json.RawMessage", "nullable": true } }
{ "name": "json", "type": "other", "typeInfo": { "frame": "json.RawMessage" } },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty printed

Copy link
Contributor

@kylebrandt kylebrandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off at the moment, so might be good if todd or Sriram approve as well with a bit more eye to detail..., but perhaps they are off as well.

I'm very excited about being able to add some sort of url field type (title + link) - ( not sure offhand if the go url type would be appropriate). And perhaps a variation that is more grafana specific for linking between tables and traces etc! All of which I believe this unlocks if I not mistaken.

+100 for finding a way forward without an arrow removal dependency!

@ryantxu ryantxu merged commit cb6cd94 into main Dec 14, 2022
@ryantxu ryantxu deleted the add-typescript-type-to-arrow-metadata branch December 14, 2022 16:15
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

Successfully merging this pull request may close these issues.

None yet

2 participants