You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/10/21 23:23:55 UTC

[GitHub] [arrow] zeroshade opened a new pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

zeroshade opened a new pull request #11514:
URL: https://github.com/apache/arrow/pull/11514


   This is for preparation of connecting to the Compute API, building out the support for Datums, Field Referencing and Field Paths, and Expression handling.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r778565423



##########
File path: go/arrow/compute/utils.go
##########
@@ -0,0 +1,83 @@
+// 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 compute

Review comment:
       ssmall nit, this seems orthogonal to compute (it seems like a general buffer class?)




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Failed :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Finished :arrow_down:0.04% :arrow_up:0.04%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1005025162


   Thanks much and happy new year to you too! :) Hope all is well, I'm literally just recovering from Covid myself so I completely understand haha. :)


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Failed :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744999461



##########
File path: go/arrow/array/util.go
##########
@@ -16,6 +16,38 @@
 
 package array
 
+import (
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/memory"
+)
+
+// RecordToStructArray constructs a struct array from the columns of the record batch
+// by referencing them, zero-copy.
+func RecordToStructArray(rec Record) *Struct {
+	cols := make([]*Data, rec.NumCols())
+	for i, c := range rec.Columns() {
+		cols[i] = c.Data()
+	}
+
+	data := NewData(arrow.StructOf(rec.Schema().Fields()...), int(rec.NumRows()), []*memory.Buffer{nil}, cols, 0, 0)
+	defer data.Release()
+
+	return NewStructData(data)
+}
+
+// RecordFromStructArray is a convenience function for converting a struct array into
+// a record batch without copying the data. If the passed in schema is nil, the fields
+// of the struct will be used to define the record batch. Otherwise the passed in
+// schema will be used to create the record batch. If passed in, the schema must match
+// the fields of the struct column.
+func RecordFromStructArray(in *Struct, schema *arrow.Schema) Record {

Review comment:
       Yea, i mirrored the C++ implementation here and drop the top-level bitmap. I'll update the comment.




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r778565748



##########
File path: go/arrow/datatype_fixedwidth.go
##########
@@ -220,17 +220,17 @@ func (t Time64) ToTime(unit TimeUnit) time.Time {
 }
 
 const (
-	Nanosecond TimeUnit = iota
-	Microsecond
+	Second TimeUnit = iota
 	Millisecond
-	Second
+	Microsecond

Review comment:
       does this reordering have any semantic impacts?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744023225



##########
File path: go/arrow/compute/expression.go
##########
@@ -0,0 +1,954 @@
+// 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 compute
+
+import (
+	"bytes"
+	"context"
+	"encoding/hex"
+	"errors"
+	"fmt"
+	"hash/maphash"
+	"reflect"
+	"strconv"
+	"strings"
+
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/array"
+	"github.com/apache/arrow/go/arrow/internal/debug"
+	"github.com/apache/arrow/go/arrow/ipc"
+	"github.com/apache/arrow/go/arrow/memory"
+	"github.com/apache/arrow/go/arrow/scalar"
+)
+
+var hashSeed = maphash.MakeSeed()
+
+// Expression is an interface for mapping one datum to another. An expression
+// is one of:
+//	A literal Datum
+// 	A reference to a single (potentially nested) field of an input Datum
+//	A call to a compute function, with arguments specified by other Expressions
+type Expression interface {
+	fmt.Stringer
+	// IsBound returns true if this expression has been bound to a particular
+	// Datum and/or Schema.
+	IsBound() bool
+	// IsScalarExpr returns true if this expression is composed only of scalar
+	// literals, field references and calls to scalar functions.
+	IsScalarExpr() bool
+	// IsNullLiteral returns true if this expression is a literal and entirely
+	// null.
+	IsNullLiteral() bool
+	// IsSatisfiable returns true if this expression could evaluate to true
+	IsSatisfiable() bool
+	// FieldRef returns a pointer to the underlying field reference, or nil if
+	// this expression is not a field reference.
+	FieldRef() *FieldRef
+	// Descr returns the shape of this expression will evaluate to including the type
+	// and whether it will be an Array, Scalar, or either.
+	Descr() ValueDescr
+	// Type returns the datatype this expression will evaluate to.
+	Type() arrow.DataType
+
+	Hash() uint64
+	Equals(Expression) bool
+
+	// Bind binds this expression to the given input schema, looking up appropriate
+	// underlying implementations and some expression simplification may be performed
+	// along with implicit casts being inserted.
+	// Any state necessary for execution will be initialized.
+	//
+	// This only works in conjunction with cgo and being able to link against the
+	// C++ libarrow.so compute library. If this was not built with the libarrow compute
+	// support, this will panic.
+	Bind(context.Context, memory.Allocator, *arrow.Schema) (Expression, error)
+
+	// Release releases the underlying bound C++ memory that is allocated when
+	// a Bind is performed. Any bound expression should get released to ensure
+	// no memory leaks.
+	Release()
+
+	boundExpr() boundRef
+}
+
+func printDatum(datum Datum) string {
+	switch datum := datum.(type) {
+	case *ScalarDatum:
+		if !datum.Value.IsValid() {
+			return "null"
+		}
+
+		switch datum.Type().ID() {
+		case arrow.STRING, arrow.LARGE_STRING:
+			return strconv.Quote(datum.Value.(scalar.BinaryScalar).String())
+		case arrow.BINARY, arrow.FIXED_SIZE_BINARY, arrow.LARGE_BINARY:
+			return `"` + strings.ToUpper(hex.EncodeToString(datum.Value.(scalar.BinaryScalar).Data())) + `"`
+		}
+
+		return datum.Value.String()
+	default:
+		return datum.String()
+	}
+}
+
+// Literal is an expression denoting a literal Datum which could be any value
+// as a scalar, an array, or so on.
+type Literal struct {
+	Literal Datum
+
+	bound boundRef
+}
+
+func (Literal) FieldRef() *FieldRef     { return nil }
+func (l *Literal) String() string       { return printDatum(l.Literal) }
+func (l *Literal) boundExpr() boundRef  { return l.bound }
+func (l *Literal) Type() arrow.DataType { return l.Literal.(ArrayLikeDatum).Type() }
+func (l *Literal) IsBound() bool        { return l.Type() != nil }
+func (l *Literal) IsScalarExpr() bool   { return l.Literal.Kind() == KindScalar }
+
+func (l *Literal) Equals(other Expression) bool {
+	if rhs, ok := other.(*Literal); ok {
+		return l.Literal.Equals(rhs.Literal)
+	}
+	return false
+}
+
+func (l *Literal) IsNullLiteral() bool {
+	if ad, ok := l.Literal.(ArrayLikeDatum); ok {
+		return ad.NullN() == ad.Len()
+	}
+	return true
+}
+
+func (l *Literal) IsSatisfiable() bool {
+	if l.IsNullLiteral() {
+		return false
+	}
+
+	if sc, ok := l.Literal.(*ScalarDatum); ok && sc.Type().ID() == arrow.BOOL {

Review comment:
       so an error returns false?  What case does happen in?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] asfgit closed pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #11514:
URL: https://github.com/apache/arrow/pull/11514


   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r778899010



##########
File path: go/arrow/compute/utils.go
##########
@@ -0,0 +1,83 @@
+// 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 compute

Review comment:
       it is a general buffer class, I wanted to ensure performance for the serialize/deserialize of the expressions with the ipc handler so I needed a buffer that could meet the io.Writer and io.Seeker interfaces efficiently and generate a `memory.Buffer` without extra copies of the data. That's why it's not exported from this package (doesn't start with an uppercase letter)




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744022409



##########
File path: go/arrow/compute/datumkind_string.go
##########
@@ -0,0 +1,29 @@
+// Code generated by "stringer -type=DatumKind -linecomment"; DO NOT EDIT.
+
+package compute
+
+import "strconv"
+
+func _() {
+	// An "invalid array index" compiler error signifies that the constant values have changed.
+	// Re-run the stringer command to generate them again.
+	var x [1]struct{}
+	_ = x[KindNone-0]
+	_ = x[KindScalar-1]
+	_ = x[KindArray-2]
+	_ = x[KindChunked-3]
+	_ = x[KindRecord-4]
+	_ = x[KindTable-5]
+	_ = x[KindCollection-6]
+}
+
+const _DatumKind_name = "nonescalararraychunked_arrayrecord_batchtablecollection"
+
+var _DatumKind_index = [...]uint8{0, 4, 10, 15, 28, 40, 45, 55}

Review comment:
       Not sure I understand this array?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744028998



##########
File path: go/arrow/compute/expression.go
##########
@@ -0,0 +1,954 @@
+// 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 compute
+
+import (
+	"bytes"
+	"context"
+	"encoding/hex"
+	"errors"
+	"fmt"
+	"hash/maphash"
+	"reflect"
+	"strconv"
+	"strings"
+
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/array"
+	"github.com/apache/arrow/go/arrow/internal/debug"
+	"github.com/apache/arrow/go/arrow/ipc"
+	"github.com/apache/arrow/go/arrow/memory"
+	"github.com/apache/arrow/go/arrow/scalar"
+)
+
+var hashSeed = maphash.MakeSeed()
+
+// Expression is an interface for mapping one datum to another. An expression
+// is one of:
+//	A literal Datum
+// 	A reference to a single (potentially nested) field of an input Datum
+//	A call to a compute function, with arguments specified by other Expressions
+type Expression interface {
+	fmt.Stringer
+	// IsBound returns true if this expression has been bound to a particular
+	// Datum and/or Schema.
+	IsBound() bool
+	// IsScalarExpr returns true if this expression is composed only of scalar
+	// literals, field references and calls to scalar functions.
+	IsScalarExpr() bool
+	// IsNullLiteral returns true if this expression is a literal and entirely
+	// null.
+	IsNullLiteral() bool
+	// IsSatisfiable returns true if this expression could evaluate to true
+	IsSatisfiable() bool
+	// FieldRef returns a pointer to the underlying field reference, or nil if
+	// this expression is not a field reference.
+	FieldRef() *FieldRef
+	// Descr returns the shape of this expression will evaluate to including the type
+	// and whether it will be an Array, Scalar, or either.
+	Descr() ValueDescr
+	// Type returns the datatype this expression will evaluate to.
+	Type() arrow.DataType
+
+	Hash() uint64
+	Equals(Expression) bool
+
+	// Bind binds this expression to the given input schema, looking up appropriate
+	// underlying implementations and some expression simplification may be performed
+	// along with implicit casts being inserted.
+	// Any state necessary for execution will be initialized.
+	//
+	// This only works in conjunction with cgo and being able to link against the
+	// C++ libarrow.so compute library. If this was not built with the libarrow compute
+	// support, this will panic.
+	Bind(context.Context, memory.Allocator, *arrow.Schema) (Expression, error)
+
+	// Release releases the underlying bound C++ memory that is allocated when
+	// a Bind is performed. Any bound expression should get released to ensure
+	// no memory leaks.
+	Release()
+
+	boundExpr() boundRef
+}
+
+func printDatum(datum Datum) string {
+	switch datum := datum.(type) {
+	case *ScalarDatum:
+		if !datum.Value.IsValid() {
+			return "null"
+		}
+
+		switch datum.Type().ID() {
+		case arrow.STRING, arrow.LARGE_STRING:
+			return strconv.Quote(datum.Value.(scalar.BinaryScalar).String())
+		case arrow.BINARY, arrow.FIXED_SIZE_BINARY, arrow.LARGE_BINARY:
+			return `"` + strings.ToUpper(hex.EncodeToString(datum.Value.(scalar.BinaryScalar).Data())) + `"`
+		}
+
+		return datum.Value.String()
+	default:
+		return datum.String()
+	}
+}
+
+// Literal is an expression denoting a literal Datum which could be any value
+// as a scalar, an array, or so on.
+type Literal struct {
+	Literal Datum
+
+	bound boundRef
+}
+
+func (Literal) FieldRef() *FieldRef     { return nil }
+func (l *Literal) String() string       { return printDatum(l.Literal) }
+func (l *Literal) boundExpr() boundRef  { return l.bound }
+func (l *Literal) Type() arrow.DataType { return l.Literal.(ArrayLikeDatum).Type() }
+func (l *Literal) IsBound() bool        { return l.Type() != nil }
+func (l *Literal) IsScalarExpr() bool   { return l.Literal.Kind() == KindScalar }
+
+func (l *Literal) Equals(other Expression) bool {
+	if rhs, ok := other.(*Literal); ok {
+		return l.Literal.Equals(rhs.Literal)
+	}
+	return false
+}
+
+func (l *Literal) IsNullLiteral() bool {
+	if ad, ok := l.Literal.(ArrayLikeDatum); ok {
+		return ad.NullN() == ad.Len()
+	}
+	return true
+}
+
+func (l *Literal) IsSatisfiable() bool {
+	if l.IsNullLiteral() {
+		return false
+	}
+
+	if sc, ok := l.Literal.(*ScalarDatum); ok && sc.Type().ID() == arrow.BOOL {

Review comment:
       I'm not sure i understand your meaning. the logic here is:
   
   ```
   if L is a null literal: return false
   if L is a boolean scalar: return the value of the scalar bool
   otherwise return true
   ```
   




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1005023871


   Yes, sorry I will take a look tonight, hopefully getting back into a routine this week.  Happy new year.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1004956504


   @emkornfield As with the parquet writer, if at all possible, I'd like to get this merged for v7 if you can carve some time out to give this a review. Thanks much!


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744028562



##########
File path: go/arrow/compute/datumkind_string.go
##########
@@ -0,0 +1,29 @@
+// Code generated by "stringer -type=DatumKind -linecomment"; DO NOT EDIT.
+
+package compute
+
+import "strconv"
+
+func _() {
+	// An "invalid array index" compiler error signifies that the constant values have changed.
+	// Re-run the stringer command to generate them again.
+	var x [1]struct{}
+	_ = x[KindNone-0]
+	_ = x[KindScalar-1]
+	_ = x[KindArray-2]
+	_ = x[KindChunked-3]
+	_ = x[KindRecord-4]
+	_ = x[KindTable-5]
+	_ = x[KindCollection-6]
+}
+
+const _DatumKind_name = "nonescalararraychunked_arrayrecord_batchtablecollection"
+
+var _DatumKind_index = [...]uint8{0, 4, 10, 15, 28, 40, 45, 55}

Review comment:
       this file is actually a generated file using the "stringer" command, amusingly if you look at this and the value of `_DatumKind_name` together, they are effectively an arrow string array. these are the offsets into the string to get the `.String()` value for the enum values.
   
   But like i said, this is generated by running `go generate` and is not something hand written.




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Failed] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-949074577






-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-977502612


   sorry will try to carve out some time this weekend to finish reviewing


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744020687



##########
File path: go/arrow/array/util.go
##########
@@ -16,6 +16,38 @@
 
 package array
 
+import (
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/memory"
+)
+
+// RecordToStructArray constructs a struct array from the columns of the record batch
+// by referencing them, zero-copy.
+func RecordToStructArray(rec Record) *Struct {
+	cols := make([]*Data, rec.NumCols())
+	for i, c := range rec.Columns() {
+		cols[i] = c.Data()
+	}
+
+	data := NewData(arrow.StructOf(rec.Schema().Fields()...), int(rec.NumRows()), []*memory.Buffer{nil}, cols, 0, 0)
+	defer data.Release()
+
+	return NewStructData(data)
+}
+
+// RecordFromStructArray is a convenience function for converting a struct array into
+// a record batch without copying the data. If the passed in schema is nil, the fields
+// of the struct will be used to define the record batch. Otherwise the passed in
+// schema will be used to create the record batch. If passed in, the schema must match
+// the fields of the struct column.
+func RecordFromStructArray(in *Struct, schema *arrow.Schema) Record {

Review comment:
       Please document what happens to the top level null-bitmap?  Does it get distributed to child arrays or dropped (from the implementation it looks like it is dropped?)




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot commented on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot commented on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Scheduled] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] ursabot edited a comment on pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#issuecomment-1006061615


   Benchmark runs are scheduled for baseline = ec38aebb36e99e54e69089cbc6a623a616575dde and contender = d30669b7f27f60b20f02c45f1e4ca22f4abd06e1. d30669b7f27f60b20f02c45f1e4ca22f4abd06e1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/1b5e3a4ab1db415ca90ec502fccedb4f...85d18f60d1fa465787b3221f9c534787/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ffe8032605144c5388649c3edf75a52a...fc2bdab239f34476a028186fd5fa217e/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/924ad696374942ce813258bde7c2334e...a899722c433f4d13b5b038367a85d45a/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] zeroshade commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
zeroshade commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r778899954



##########
File path: go/arrow/datatype_fixedwidth.go
##########
@@ -220,17 +220,17 @@ func (t Time64) ToTime(unit TimeUnit) time.Time {
 }
 
 const (
-	Nanosecond TimeUnit = iota
-	Microsecond
+	Second TimeUnit = iota
 	Millisecond
-	Second
+	Microsecond

Review comment:
       It did, which is why there are the corresponding re-orderings below it in the `Multiplier` and `String` functions. There should be no other semantic impacts other than that though since nothing else should be depending on the actual numeric value of the enum.




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744021168



##########
File path: go/arrow/compute/datum.go
##########
@@ -0,0 +1,346 @@
+// 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 compute
+
+import (
+	"fmt"
+	"strings"
+
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/array"
+	"github.com/apache/arrow/go/arrow/scalar"
+)
+
+//go:generate go run golang.org/x/tools/cmd/stringer -type=ValueShape -linecomment
+//go:generate go run golang.org/x/tools/cmd/stringer -type=DatumKind -linecomment
+
+// ValueShape is a brief description of the shape of a value (array, scalar or otherwise)
+type ValueShape int8
+
+const (
+	// either Array or Scalar
+	ShapeAny    ValueShape = iota // any
+	ShapeArray                    // array
+	ShapeScalar                   // scalar
+)
+
+// ValueDescr is a descriptor type giving both the shape and the datatype of a value
+// but without the data.
+type ValueDescr struct {
+	Shape ValueShape
+	Type  arrow.DataType
+}
+
+func (v *ValueDescr) String() string {
+	return fmt.Sprintf("%s [%s]", v.Shape, v.Type)
+}
+
+// DatumKind is an enum used for denoting which kind of type a datum is encapsulating
+type DatumKind int
+
+const (
+	KindNone       DatumKind = iota // none

Review comment:
       Just a side note, I'm not sure if all of these are actually used in the C++ implementation. 




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #11514: ARROW-14430: [Go] Basic Expression, Field Reference and Datum handling

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744020732



##########
File path: go/arrow/array/util.go
##########
@@ -16,6 +16,38 @@
 
 package array
 
+import (
+	"github.com/apache/arrow/go/arrow"
+	"github.com/apache/arrow/go/arrow/memory"
+)
+
+// RecordToStructArray constructs a struct array from the columns of the record batch
+// by referencing them, zero-copy.
+func RecordToStructArray(rec Record) *Struct {
+	cols := make([]*Data, rec.NumCols())
+	for i, c := range rec.Columns() {
+		cols[i] = c.Data()
+	}
+
+	data := NewData(arrow.StructOf(rec.Schema().Fields()...), int(rec.NumRows()), []*memory.Buffer{nil}, cols, 0, 0)
+	defer data.Release()
+
+	return NewStructData(data)
+}
+
+// RecordFromStructArray is a convenience function for converting a struct array into
+// a record batch without copying the data. If the passed in schema is nil, the fields
+// of the struct will be used to define the record batch. Otherwise the passed in
+// schema will be used to create the record batch. If passed in, the schema must match
+// the fields of the struct column.
+func RecordFromStructArray(in *Struct, schema *arrow.Schema) Record {

Review comment:
       Please document what happens to the top level null-bitmap?  Does it get distributed to child arrays or dropped (from the implementation it looks like it is dropped?)




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org