Skip to content

Commit

Permalink
ARROW-17326: [Go][FlightSQL] Add FlightSQL support for Go (#13828)
Browse files Browse the repository at this point in the history
This implements initial support for FlightSQL in Golang and is sufficient to pass the flight_sql integration scenario.

As a follow-up in a subsequent PR i'll implement an equivalent example to the C++ SQLite example using Go.

Also closes #12496

Authored-by: Matt Topol <[email protected]>
Signed-off-by: Matt Topol <[email protected]>
  • Loading branch information
zeroshade authored Aug 11, 2022
1 parent 89b39bc commit e8ed4c2
Show file tree
Hide file tree
Showing 34 changed files with 8,154 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dev/archery/archery/integration/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def run_all_tests(with_cpp=True, with_java=True, with_js=True,
Scenario(
"flight_sql",
description="Ensure Flight SQL protocol is working as expected.",
skip={"Rust", "Go"}
skip={"Rust"}
),
]

Expand Down
2 changes: 1 addition & 1 deletion format/Flight.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
syntax = "proto3";

option java_package = "org.apache.arrow.flight.impl";
option go_package = "github.com/apache/arrow/go/flight;flight";
option go_package = "github.com/apache/arrow/go/arrow/flight/internal/flight";
option csharp_namespace = "Apache.Arrow.Flight.Protocol";

package arrow.flight.protocol;
Expand Down
1 change: 1 addition & 0 deletions format/FlightSql.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ syntax = "proto3";
import "google/protobuf/descriptor.proto";

option java_package = "org.apache.arrow.flight.sql.impl";
option go_package = "github.com/apache/arrow/go/arrow/flight/internal/flight";
package arrow.flight.protocol.sql;

/*
Expand Down
4 changes: 4 additions & 0 deletions go/arrow/array/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func NewRecord(schema *arrow.Schema, cols []arrow.Array, nrows int64) *simpleRec
}

func (rec *simpleRecord) validate() error {
if rec.rows == 0 && len(rec.arrs) == 0 {
return nil
}

if len(rec.arrs) != len(rec.schema.Fields()) {
return fmt.Errorf("arrow/array: number of columns/fields mismatch")
}
Expand Down
3 changes: 1 addition & 2 deletions go/arrow/array/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ func TestRecord(t *testing.T) {
{
schema: schema,
cols: nil,
rows: -1,
err: fmt.Errorf("arrow/array: number of columns/fields mismatch"),
rows: 0,
},
{
schema: schema,
Expand Down
11 changes: 11 additions & 0 deletions go/arrow/array/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ type UnionBuilder interface {
// Mode returns what kind of Union is being built, either arrow.SparseMode
// or arrow.DenseMode
Mode() arrow.UnionMode
// Child returns the builder for the requested child index.
// If an invalid index is requested (e.g. <0 or >len(children))
// then this will panic.
Child(idx int) Builder
}

type unionBuilder struct {
Expand Down Expand Up @@ -734,6 +738,13 @@ func newUnionBuilder(mem memory.Allocator, children []Builder, typ arrow.UnionTy
return b
}

func (b *unionBuilder) Child(idx int) Builder {
if idx < 0 || idx > len(b.children) {
panic("arrow/array: invalid child index for union builder")
}
return b.children[idx]
}

func (b *unionBuilder) Mode() arrow.UnionMode { return b.mode }

func (b *unionBuilder) reserve(elements int, resize func(int)) {
Expand Down
Loading

0 comments on commit e8ed4c2

Please sign in to comment.