cocoa-xu commented on code in PR #1722:
URL: https://github.com/apache/arrow-adbc/pull/1722#discussion_r1573179165


##########
go/adbc/driver/bigquery/connection.go:
##########
@@ -0,0 +1,331 @@
+// 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 bigquery
+
+import (
+       "context"
+       "fmt"
+       "github.com/apache/arrow-adbc/go/adbc"
+       "github.com/apache/arrow-adbc/go/adbc/driver/internal/driverbase"
+       "github.com/apache/arrow/go/v16/arrow"
+       "github.com/apache/arrow/go/v16/arrow/array"
+       "github.com/apache/arrow/go/v16/arrow/memory"
+)
+
+type ConnectionImpl struct {
+       driverbase.ConnectionImplBase
+       database *databaseImpl
+       alloc    memory.Allocator
+}
+
+// NewStatement initializes a new statement object tied to this connection
+func (c *ConnectionImpl) NewStatement() (adbc.Statement, error) {
+       return &statement{
+               ConnectionImpl: c,
+               alloc:          c.alloc,
+       }, nil
+}
+
+// Close closes this connection and releases any associated resources.
+func (c *ConnectionImpl) Close() error {
+       return nil
+}
+
+func (c *ConnectionImpl) GetOption(key string) (string, error) {
+       switch key {
+       default:
+               val, err := c.database.GetOption(key)
+               if err == nil {
+                       return val, nil
+               }
+               return "", err
+       }
+}
+
+func (c *ConnectionImpl) GetOptionBytes(key string) ([]byte, error) {
+       switch key {
+       default:
+               val, err := c.ConnectionImplBase.GetOptionBytes(key)
+               if err == nil {
+                       return val, nil
+               }
+               return nil, adbc.Error{
+                       Code: adbc.StatusInvalidArgument,
+                       Msg:  fmt.Sprintf("unknown connection bytes type option 
`%s`", key),
+               }
+       }
+}
+
+func (c *ConnectionImpl) GetOptionInt(key string) (int64, error) {
+       switch key {
+       default:
+               val, err := c.ConnectionImplBase.GetOptionInt(key)
+               if err == nil {
+                       return val, nil
+               }
+               return 0, adbc.Error{
+                       Code: adbc.StatusInvalidArgument,
+                       Msg:  fmt.Sprintf("unknown connection int type option 
`%s`", key),
+               }
+       }
+}
+
+func (c *ConnectionImpl) GetOptionDouble(key string) (float64, error) {
+       switch key {
+       default:
+               val, err := c.ConnectionImplBase.GetOptionDouble(key)
+               if err == nil {
+                       return val, nil
+               }
+               return 0, adbc.Error{
+                       Code: adbc.StatusInvalidArgument,
+                       Msg:  fmt.Sprintf("unknown connection double type 
option `%s`", key),
+               }
+       }
+}
+
+func (c *ConnectionImpl) SetOptions(options map[string]string) error {
+       return adbc.Error{
+               Code: adbc.StatusInvalidArgument,
+               Msg:  "unknown connection string type option",
+       }
+}
+
+func (c *ConnectionImpl) SetOption(key string, value string) error {
+       return adbc.Error{
+               Code: adbc.StatusInvalidArgument,
+               Msg:  fmt.Sprintf("unknown connection string type option `%s`", 
key),
+       }
+}
+
+func (c *ConnectionImpl) SetOptionBytes(key string, value []byte) error {
+       return adbc.Error{
+               Code: adbc.StatusInvalidArgument,
+               Msg:  fmt.Sprintf("unknown connection bytes type option `%s`", 
key),
+       }
+}
+
+func (c *ConnectionImpl) SetOptionInt(key string, value int64) error {
+       return adbc.Error{
+               Code: adbc.StatusInvalidArgument,
+               Msg:  fmt.Sprintf("unknown connection int type option `%s`", 
key),
+       }
+}
+
+func (c *ConnectionImpl) SetOptionDouble(key string, value float64) error {
+       return adbc.Error{
+               Code: adbc.StatusInvalidArgument,
+               Msg:  fmt.Sprintf("unknown connection double type option `%s`", 
key),
+       }
+}
+
+// ReadPartition constructs a statement for a partition of a query. The
+// results can then be read independently using the returned RecordReader.
+//
+// A partition can be retrieved by using ExecutePartitions on a statement.
+func (c *ConnectionImpl) ReadPartition(ctx context.Context, 
serializedPartition []byte) (array.RecordReader, error) {
+       return nil, adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "ReadPartition not yet implemented for BigQuery driver",
+       }
+}
+
+// ListTableTypes implements driverbase.TableTypeLister.
+func (c *ConnectionImpl) ListTableTypes(ctx context.Context) ([]string, error) 
{
+       return []string{"BASE TABLE", "TEMPORARY TABLE", "VIEW"}, nil
+}
+
+// GetCurrentCatalog implements driverbase.CurrentNamespacer.
+func (c *ConnectionImpl) GetCurrentCatalog() (string, error) {
+       return "", adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "GetCurrentCatalog not yet implemented for BigQuery 
driver",
+       }
+}
+
+// GetCurrentDbSchema implements driverbase.CurrentNamespacer.
+func (c *ConnectionImpl) GetCurrentDbSchema() (string, error) {
+       return "", adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "GetCurrentDbSchema not yet implemented for BigQuery 
driver",
+       }
+}
+
+// SetCurrentCatalog implements driverbase.CurrentNamespacer.
+func (c *ConnectionImpl) SetCurrentCatalog(value string) error {
+       return adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "SetCurrentCatalog not yet implemented for BigQuery 
driver",
+       }
+}
+
+// SetCurrentDbSchema implements driverbase.CurrentNamespacer.
+func (c *ConnectionImpl) SetCurrentDbSchema(value string) error {
+       return adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "SetCurrentDbSchema not yet implemented for BigQuery 
driver",
+       }
+}
+
+// SetAutocommit implements driverbase.AutocommitSetter.
+func (c *ConnectionImpl) SetAutocommit(enabled bool) error {
+       return adbc.Error{
+               Code: adbc.StatusNotImplemented,
+               Msg:  "SetAutocommit not yet implemented for BigQuery driver",
+       }
+}
+
+// Metadata methods
+// Generally these methods return an array.RecordReader that
+// can be consumed to retrieve metadata about the database as Arrow
+// data. The returned metadata has an expected schema given in the
+// doc strings of the specific methods. Schema fields are nullable
+// unless otherwise marked. While no Statement is used in these
+// methods, the result set may count as an active statement to the
+// driver for the purposes of concurrency management (e.g. if the
+// driver has a limit on concurrent active statements and it must
+// execute a SQL query internally in order to implement the metadata
+// method).
+//
+// Some methods accept "search pattern" arguments, which are strings
+// that can contain the special character "%" to match zero or more
+// characters, or "_" to match exactly one character. (See the
+// documentation of DatabaseMetaData in JDBC or "Pattern Value Arguments"
+// in the ODBC documentation.) Escaping is not currently supported.
+// GetObjects gets a hierarchical view of all catalogs, database schemas,
+// tables, and columns.
+//
+// The result is an Arrow Dataset with the following schema:
+//
+//     Field Name                                                              
        | Field Type
+//     ----------------------------|----------------------------
+//     catalog_name                                                            
| utf8
+//     catalog_db_schemas                                      | 
list<DB_SCHEMA_SCHEMA>
+//
+// DB_SCHEMA_SCHEMA is a Struct with the fields:
+//
+//     Field Name                                                              
        | Field Type
+//     ----------------------------|----------------------------
+//     db_schema_name                                                  | utf8
+//     db_schema_tables                                                |       
list<TABLE_SCHEMA>
+//
+// TABLE_SCHEMA is a Struct with the fields:

Review Comment:
   Sorry this was copied from `driver/snowflake/connection.go` and I thought 
they were kept that way so `\t` works...



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