felipecrv commented on code in PR #34079:
URL: https://github.com/apache/arrow/pull/34079#discussion_r1100793541


##########
go/arrow/scalar/nested.go:
##########
@@ -744,3 +745,72 @@ func (s *DenseUnion) ChildValue() Scalar { return s.Value }
 func NewDenseUnionScalar(v Scalar, code arrow.UnionTypeCode, dt 
*arrow.DenseUnionType) *DenseUnion {
        return &DenseUnion{scalar: scalar{dt, v.IsValid()}, TypeCode: code, 
Value: v}
 }
+
+type RunEndEncoded struct {
+       scalar
+
+       RunLength int64
+       Value     Scalar
+}
+
+func NewRunEndEncodedScalar(v Scalar, runLength int64, dt 
*arrow.RunEndEncodedType) *RunEndEncoded {
+       return &RunEndEncoded{scalar: scalar{dt, true}, RunLength: runLength, 
Value: v}
+}
+
+func (s *RunEndEncoded) Release() {
+       if r, ok := s.Value.(Releasable); ok {
+               r.Release()
+       }
+}
+
+func (s *RunEndEncoded) value() interface{} { return s.Value.value() }
+
+func (s *RunEndEncoded) Validate() (err error) {
+       if err = s.Value.Validate(); err != nil {
+               return
+       }
+
+       if err = validateOptional(&s.scalar, s.value(), "value"); err != nil {
+               return
+       }
+
+       if !s.Valid {
+               return
+       }
+
+       if s.Type.ID() != arrow.RUN_END_ENCODED {
+               err = fmt.Errorf("%w: run-end-encoded scalar should not have 
type %s",
+                       arrow.ErrInvalid, s.Type)
+       }
+       return
+}
+
+func (s *RunEndEncoded) ValidateFull() error { return s.Validate() }
+
+func (s *RunEndEncoded) equals(rhs Scalar) bool {
+       other := rhs.(*RunEndEncoded)
+       return s.RunLength == other.RunLength && Equals(s.Value, other.Value)
+}
+
+func (s *RunEndEncoded) String() string {
+       return fmt.Sprintf("{run_length=%d, value=%v}",
+               s.RunLength, s.Value)
+}
+
+func (s *RunEndEncoded) CastTo(to arrow.DataType) (Scalar, error) {
+       if !s.Valid {

Review Comment:
   In some type systems (like Scala's) `Null` is a sub-type of every reference 
type meaning that a null reference to any  type T can be used where a T is 
expected (`T :> Null`). So this is logically sound.
   
   
![image](https://user-images.githubusercontent.com/207795/217675820-f8b2be08-2e75-43c5-b0f2-c6dcf5c3c635.png)
   



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