lostluck commented on code in PR #23450:
URL: https://github.com/apache/beam/pull/23450#discussion_r993681800


##########
sdks/go/pkg/beam/transforms/xlang/python/external.go:
##########
@@ -0,0 +1,129 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package python contains data structures required for python external 
transforms in a multilanguage pipeline.
+package python
+
+import (
+       "fmt"
+       "io"
+       "reflect"
+
+       "github.com/apache/beam/sdks/v2/go/pkg/beam"
+       "github.com/apache/beam/sdks/v2/go/pkg/beam/core/graph/coder"
+       "github.com/apache/beam/sdks/v2/go/pkg/beam/core/util/reflectx"
+)
+
+const (
+       pythonCallableUrn = "beam:logical_type:python_callable:v1"
+)
+
+var (
+       pcsType        = reflect.TypeOf((*CallableSource)(nil)).Elem()
+       pcsStorageType = reflectx.String
+)
+
+func init() {
+       beam.RegisterType(pcsType)
+       beam.RegisterSchemaProviderWithURN(pcsType, &CallableSourceProvider{}, 
pythonCallableUrn)
+}
+
+// CallableSource is a wrapper object storing a Python function definition
+// that can be evaluated to Python callables in Python SDK.
+//
+// The snippet of Python code can be a valid Python expression such as
+//    lambda x: x * x
+//       str.upper
+// a fully qualified name such as
+//    math.sin
+// or a complete multi-line function or class definition such as
+//    def foo(x):
+//        ...
+//    class Foo:
+//        ...
+//
+// Any lines preceding the function definition are first evaluated to provide 
context in which to
+// define the function which can be useful to declare imports or any other 
needed values, e.g.
+//    import math
+//
+//    def helper(x):
+//        return x * x
+//
+//    def func(y):
+//        return helper(y) + y
+// in which case `func` would get applied to each element.
+type CallableSource string
+
+// CallableSourceProvider implement the SchemaProvider interface for logical 
types
+type CallableSourceProvider struct{}

Review Comment:
   This still isn't used outside of the package, please unexport it. (rename to 
`callableSourceProvider`)



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to