[
https://issues.apache.org/jira/browse/BEAM-9615?focusedWorklogId=553276&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-553276
]
ASF GitHub Bot logged work on BEAM-9615:
----------------------------------------
Author: ASF GitHub Bot
Created on: 17/Feb/21 00:27
Start Date: 17/Feb/21 00:27
Worklog Time Spent: 10m
Work Description: lostluck commented on a change in pull request #13940:
URL: https://github.com/apache/beam/pull/13940#discussion_r577233304
##########
File path: sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go
##########
@@ -102,52 +159,104 @@ func (r *Registry) registerType(ut reflect.Type, seen
map[reflect.Type]struct{})
if lID, ok := r.logicalTypeIdentifiers[t]; ok {
lt := r.logicalTypes[lID]
r.addToMaps(lt.StorageType(), t)
- return
+ return nil
}
- for _, lti := range r.logicalTypeInterfaces {
- if !t.Implements(lti) {
- continue
- }
+
+ useProvider := func(t, lti reflect.Type) (bool, error) {
p := r.logicalTypeProviders[lti]
st, err := p(t)
if err != nil {
- panic(errors.Wrapf(err, "unable to convert
LogicalType[%v] using provider for %v", t, lti))
+ return false, errors.Wrapf(err, "unable to convert
LogicalType[%v] using provider for %v", t, lti)
}
if st == nil {
- continue
+ return false, nil
}
r.RegisterLogicalType(ToLogicalType(t.String(), t, st))
r.addToMaps(st, t)
- return
+ return true, nil
+ }
+
+ for _, lti := range r.logicalTypeInterfaces {
+ if t.Implements(lti) {
+ ok, err := useProvider(t, lti)
+ if err != nil {
+ return err
+ }
+ if ok {
+ return nil
+ }
+ }
+ if t := reflect.PtrTo(t); t.Implements(lti) {
+ ok, err := useProvider(t, lti)
+ if err != nil {
+ return err
+ }
+ if ok {
+ return nil
+ }
+ }
}
switch t.Kind() {
case reflect.Map:
- r.registerType(t.Key(), seen)
+ if err := r.registerType(t.Key(), seen); err != nil {
+ return err
+ }
fallthrough
case reflect.Array, reflect.Slice, reflect.Ptr:
- r.registerType(t.Elem(), seen)
- return
+ if err := r.registerType(t.Elem(), seen); err != nil {
+ return errors.Wrapf(err, "type is of kind %v", t.Kind())
+ }
+ return nil
+ case reflect.Interface, reflect.Func, reflect.Chan, reflect.Invalid,
reflect.UnsafePointer, reflect.Uintptr:
+ // Ignore these, as they can't be serialized.
+ return nil
+ case reflect.Complex64, reflect.Complex128:
+ // TODO(BEAM-9615): Support complex number types.
+ return nil
case reflect.Struct: // What we expect here.
default:
- return
+ rt := reflectKindToTypeMap[t.Kind()]
+ // It's only a logical type if it's not a built in primitive
type.
+ if t != rt {
+ st, ok := reflectKindToTypeMap[t.Kind()]
+ if !ok {
+ fmt.Printf("\n nil type to RegisterLogicalType
for t %v\n", t)
+ return nil
+ }
+ r.RegisterLogicalType(ToLogicalType(t.String(), t, st))
+ }
+ return nil
}
runtime.RegisterType(ut)
for i := 0; i < t.NumField(); i++ {
sf := ut.Field(i)
- r.registerType(sf.Type, seen)
+ isUnexported := sf.PkgPath != ""
+ if isUnexported {
+ // Schemas can't handle unexported fields at all.
+ continue
+ }
+ if err := r.registerType(sf.Type, seen); err != nil {
+ return errors.Wrapf(err, "registering type for field %v
in %v", sf.Name, ut)
+ }
+ if implements(sf.Type, sdfRtrackerType) {
Review comment:
Technically it happens with RegisterDoFn when RegisterSchema is
included. I'm still working out the bugs, and am going with the heavy handed
approach for now.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 553276)
Time Spent: 23h 10m (was: 23h)
> [Go SDK] Beam Schemas
> ---------------------
>
> Key: BEAM-9615
> URL: https://issues.apache.org/jira/browse/BEAM-9615
> Project: Beam
> Issue Type: New Feature
> Components: sdk-go
> Reporter: Robert Burke
> Assignee: Robert Burke
> Priority: P2
> Time Spent: 23h 10m
> Remaining Estimate: 0h
>
> Schema support is required for advanced cross language features in Beam, and
> has the opportunity to replace the current default JSON encoding of elements.
> Some quick notes, though a better fleshed out doc with details will be
> forthcoming:
> * All base coders should be implemented, and listed as coder capabilities. I
> think only stringutf8 is missing presently.
> * Should support fairly arbitrary user types, seamlessly. That is, users
> should be able to rely on it "just working" if their type is compatible.
> * Should support schema metadata tagging.
> In particular, one breaking shift in the default will be to explicitly fail
> pipelines if elements have unexported fields, when no other custom coder has
> been added. This has been a source of errors/dropped data/keys and a simply
> warning at construction time won't cut it. However, we could provide a manual
> "use beam schemas, but ignore unexported fields" registration as a work
> around.
> Edit: Doc is now at https://s.apache.org/beam-go-schemas
--
This message was sent by Atlassian Jira
(v8.3.4#803005)