lidavidm commented on code in PR #322:
URL: https://github.com/apache/arrow-adbc/pull/322#discussion_r1067358732


##########
go/adbc/driver/flightsql/record_reader.go:
##########
@@ -0,0 +1,132 @@
+// 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 flightsql
+
+import (
+       "context"
+       "sync"
+       "sync/atomic"
+
+       "github.com/apache/arrow-adbc/go/adbc"
+       "github.com/apache/arrow/go/v10/arrow"
+       "github.com/apache/arrow/go/v10/arrow/array"
+       "github.com/apache/arrow/go/v10/arrow/flight"
+       "github.com/apache/arrow/go/v10/arrow/flight/flightsql"
+       "github.com/apache/arrow/go/v10/arrow/memory"
+       "github.com/bluele/gcache"
+)
+
+type reader struct {
+       refCount int64
+       schema   *arrow.Schema
+       ch       chan arrow.Record
+       rec      arrow.Record
+
+       cancelFn context.CancelFunc
+}
+
+// kicks off a goroutine for each endpoint and returns a reader which

Review Comment:
   I am jealous how easily you can do this...I'm dreading the C++ version



##########
go/adbc/driver/flightsql/flightsql_adbc.go:
##########
@@ -0,0 +1,577 @@
+// 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 flightsql is an ADBC Driver Implementation for Flight SQL
+// natively in go.
+//
+// It can be used to register a driver for database/sql by importing
+// github.com/apache/arrow-adbc/go/adbc/sqldriver and running:
+//
+//     sql.Register("flightsql", sqldriver.Driver{flightsql.Driver{}})
+//
+// You can then open a flightsql connection with the database/sql
+// standard package by using:
+//
+//     db, err := sql.Open("flightsql", "uri=<flight sql db url>")
+//
+// The URI passed *must* contain a scheme, most likely "grpc+tcp://"
+package flightsql
+
+import (
+       "context"
+       "crypto/tls"
+       "io"
+       "net/url"
+       "runtime/debug"
+       "strings"
+       "time"
+
+       "github.com/apache/arrow-adbc/go/adbc"
+       "github.com/apache/arrow/go/v10/arrow"
+       "github.com/apache/arrow/go/v10/arrow/array"
+       "github.com/apache/arrow/go/v10/arrow/flight"
+       "github.com/apache/arrow/go/v10/arrow/flight/flightsql"
+       "github.com/apache/arrow/go/v10/arrow/memory"
+       "github.com/bluele/gcache"
+       "golang.org/x/exp/maps"
+       "google.golang.org/grpc"
+       "google.golang.org/grpc/credentials"
+       "google.golang.org/grpc/credentials/insecure"
+       "google.golang.org/grpc/metadata"
+       "google.golang.org/protobuf/proto"
+)
+
+const (
+       OptionSSLInsecure = "adbc.flight.sql.client_option.tls_skip_verify"
+       OptionSSLCertFile = "adbc.flight.sql.client_option.tls_root_certs"

Review Comment:
   I wonder if we want to align between the C++/Java/Go Flight SQL drivers?



##########
go/adbc/driver/flightsql/flightsql_adbc_test.go:
##########
@@ -0,0 +1,201 @@
+// 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 flightsql_test
+
+import (
+       "context"
+       "fmt"
+       "io"
+       "os"
+       "strings"
+       "testing"
+
+       "github.com/apache/arrow-adbc/go/adbc"
+       driver "github.com/apache/arrow-adbc/go/adbc/driver/flightsql"
+       "github.com/apache/arrow-adbc/go/adbc/validation"
+       "github.com/apache/arrow/go/v10/arrow"
+       "github.com/apache/arrow/go/v10/arrow/array"
+       "github.com/apache/arrow/go/v10/arrow/flight"
+       "github.com/apache/arrow/go/v10/arrow/flight/flightsql"
+       "github.com/apache/arrow/go/v10/arrow/flight/flightsql/example"
+       "github.com/apache/arrow/go/v10/arrow/memory"
+       "github.com/stretchr/testify/require"
+       "github.com/stretchr/testify/suite"
+)
+
+type FlightSQLQuirks struct {
+       srv *example.SQLiteFlightSQLServer
+       s   flight.Server
+
+       mem *memory.CheckedAllocator
+}
+
+func (s *FlightSQLQuirks) SetupDriver(t *testing.T) adbc.Driver {
+       var err error
+       s.mem = memory.NewCheckedAllocator(memory.DefaultAllocator)
+       s.s = flight.NewServerWithMiddleware(nil)
+       s.srv, err = example.NewSQLiteFlightSQLServer()
+       require.NoError(t, err)
+       s.srv.Alloc = s.mem
+
+       s.s.RegisterFlightService(flightsql.NewFlightServer(s.srv))
+       require.NoError(t, s.s.Init("localhost:0"))
+       s.s.SetShutdownOnSignals(os.Interrupt, os.Kill)
+       go func() {
+               _ = s.s.Serve()
+       }()
+
+       return driver.Driver{Alloc: s.mem}
+}
+
+func (s *FlightSQLQuirks) TearDownDriver(t *testing.T, _ adbc.Driver) {
+       s.s.Shutdown()
+       s.srv = nil
+       s.mem.AssertSize(t, 0)
+}
+
+func (s *FlightSQLQuirks) DatabaseOptions() map[string]string {
+       return map[string]string{
+               adbc.OptionKeyURI:        "grpc+tcp://" + s.s.Addr().String(),
+               driver.OptionSSLInsecure: adbc.OptionValueEnabled,
+       }
+}
+
+func (s *FlightSQLQuirks) getSqlTypeFromArrowType(dt arrow.DataType) string {
+       switch dt.ID() {
+       case arrow.INT8, arrow.INT16, arrow.INT32, arrow.INT64:
+               return "integer"
+       case arrow.FLOAT32:
+               return "float"
+       case arrow.FLOAT64:
+               return "double"
+       case arrow.STRING:
+               return "text"
+       default:
+               return ""
+       }
+}
+
+type srvQuery string
+
+func (s srvQuery) GetQuery() string { return string(s) }
+
+func writeTo(arr arrow.Array, idx int, w io.Writer) {

Review Comment:
   Huh, this isn't built into the Arrow library itself?



##########
.pre-commit-config.yaml:
##########
@@ -52,8 +52,8 @@ repos:
     rev: v1.49.0
     hooks:
     - id: golangci-lint
-      entry: bash -c 'cd go/adbc && golangci-lint run --fix'
-      args: [--fix]
+      entry: bash -c 'cd go/adbc && golangci-lint run --fix --timeout 2m'

Review Comment:
   we're hitting the timeout??



##########
go/adbc/driver/flightsql/flightsql_adbc.go:
##########
@@ -0,0 +1,577 @@
+// 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 flightsql is an ADBC Driver Implementation for Flight SQL
+// natively in go.
+//
+// It can be used to register a driver for database/sql by importing
+// github.com/apache/arrow-adbc/go/adbc/sqldriver and running:
+//
+//     sql.Register("flightsql", sqldriver.Driver{flightsql.Driver{}})
+//
+// You can then open a flightsql connection with the database/sql
+// standard package by using:
+//
+//     db, err := sql.Open("flightsql", "uri=<flight sql db url>")
+//
+// The URI passed *must* contain a scheme, most likely "grpc+tcp://"
+package flightsql
+
+import (
+       "context"
+       "crypto/tls"
+       "io"
+       "net/url"
+       "runtime/debug"
+       "strings"
+       "time"
+
+       "github.com/apache/arrow-adbc/go/adbc"
+       "github.com/apache/arrow/go/v10/arrow"
+       "github.com/apache/arrow/go/v10/arrow/array"
+       "github.com/apache/arrow/go/v10/arrow/flight"
+       "github.com/apache/arrow/go/v10/arrow/flight/flightsql"
+       "github.com/apache/arrow/go/v10/arrow/memory"
+       "github.com/bluele/gcache"
+       "golang.org/x/exp/maps"
+       "google.golang.org/grpc"
+       "google.golang.org/grpc/credentials"
+       "google.golang.org/grpc/credentials/insecure"
+       "google.golang.org/grpc/metadata"
+       "google.golang.org/protobuf/proto"
+)
+
+const (
+       OptionSSLInsecure = "adbc.flight.sql.client_option.tls_skip_verify"
+       OptionSSLCertFile = "adbc.flight.sql.client_option.tls_root_certs"
+
+       infoDriverName = "ADBC Flight SQL Driver - Go"

Review Comment:
   Heh, the C++/Java ones should also probably include the language then.



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