proxy.golang.org : github.com/databricks/databricks-sql-go : v1.5.4
Package dbsql implements the go driver to Databricks SQL Clients should use the database/sql package in conjunction with the driver: Use sql.Open() to create a database handle via a data source name string: The DSN format is: Supported optional connection parameters can be specified in param=value and include: Supported optional session parameters can be specified in param=value and include: Use sql.OpenDB() to create a database handle via a new connector object created with dbsql.NewConnector(): Supported functional options include: Cancelling a query via context cancellation or timeout is supported. Use the driverctx package under driverctx/ctx.go to add CorrelationId and ConnId to the context. CorrelationId and ConnId makes it convenient to parse and create metrics in logging. **Connection Id** Internal id to track what happens under a connection. Connections can be reused so this would track across queries. **Query Id** Internal id to track what happens under a query. Useful because the same query can be used with multiple connections. **Correlation Id** External id, such as request ID, to track what happens under a request. Useful to track multiple connections in the same request. Use the logger package under logger.go to set up logging (from zerolog). By default, logging level is `warn`. If you want to disable logging, use `disabled`. The user can also utilize Track() and Duration() to custom log the elapsed time of anything tracked. The result log may look like this: Use the driverctx package under driverctx/ctx.go to add callbacks to the query context to receive the connection id and query id. Passing parameters to a query is supported when run against servers with version DBR 14.1. For complex types, you can specify the SQL type using the dbsql.Parameter type field. If this field is set, the value field MUST be set to a string. Please note that named and positional parameters cannot be used together in the single query. The Go driver now supports staging operations. In order to use a staging operation, you first must update the context with a list of folders that you are allowing the driver to access. After doing so, you can execute staging operations using this context using the exec context. There are three error types exposed via dbsql/errors Each type has a corresponding sentinel value which can be used with errors.Is() to determine if one of the types is present in an error chain. Example usage: See the documentation for dbsql/errors for more information. The driver supports the ability to retrieve Apache Arrow record batches. To work with record batches it is necessary to use sql.Conn.Raw() to access the underlying driver connection to retrieve a driver.Rows instance. The driver exposes two public interfaces for working with record batches from the rows sub-package: The driver.Rows instance retrieved using Conn.Raw() can be converted to a Databricks Rows instance via a type assertion, then use GetArrowBatches() to retrieve a batch iterator. If the ArrowBatchIterator is not closed it will leak resources, such as the underlying connection. Calling code must call Release() on records returned by DBSQLArrowBatchIterator.Next(). Example usage: ================================== Databricks Type --> Golang Type ================================== BOOLEAN --> bool TINYINT --> int8 SMALLINT --> int16 INT --> int32 BIGINT --> int64 FLOAT --> float32 DOUBLE --> float64 VOID --> nil STRING --> string DATE --> time.Time TIMESTAMP --> time.Time DECIMAL(p,s) --> sql.RawBytes BINARY --> sql.RawBytes ARRAY<elementType> --> sql.RawBytes STRUCT --> sql.RawBytes MAP<keyType, valueType> --> sql.RawBytes INTERVAL (year-month) --> string INTERVAL (day-time) --> string For ARRAY, STRUCT, and MAP types, sql.Scan can cast sql.RawBytes to JSON string, which can be unmarshalled to Golang arrays, maps, and structs. For example: May generate the following row:
Registry -
Documentation -
Download -
JSON
purl: pkg:golang/github.com/databricks/[email protected]
Published:
Indexed:
Related tag:
v1.5.4
- github.com/andybalholm/brotli v1.0.4
- github.com/apache/arrow/go/v12 v12.0.1
- github.com/apache/thrift v0.17.0
- github.com/coreos/go-oidc/v3 v3.5.0
- github.com/davecgh/go-spew v1.1.1
- github.com/dnephin/pflag v1.0.7
- github.com/fatih/color v1.13.0
- github.com/fsnotify/fsnotify v1.5.4
- github.com/go-jose/go-jose/v3 v3.0.0
- github.com/goccy/go-json v0.9.11
- github.com/golang/protobuf v1.5.2
- github.com/golang/snappy v0.0.4
- github.com/google/flatbuffers v2.0.8+incompatible
- github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
- github.com/hashicorp/go-cleanhttp v0.5.1
- github.com/hashicorp/go-retryablehttp v0.7.1
- github.com/joho/godotenv v1.4.0
- github.com/klauspost/asmfmt v1.3.2
- github.com/klauspost/compress v1.15.9
- github.com/klauspost/cpuid/v2 v2.0.9
- github.com/kr/text v0.2.0
- github.com/mattn/go-colorable v0.1.12
- github.com/mattn/go-isatty v0.0.19
- github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8
- github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3
- github.com/pierrec/lz4/v4 v4.1.15
- github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
- github.com/pkg/errors v0.9.1
- github.com/pmezard/go-difflib v1.0.0
- github.com/rs/zerolog v1.28.0
- github.com/stretchr/testify v1.8.1
- github.com/zeebo/xxh3 v1.0.2
- golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f
- golang.org/x/mod v0.8.0
- golang.org/x/net v0.9.0
- golang.org/x/oauth2 v0.7.0
- golang.org/x/sync v0.1.0
- golang.org/x/sys v0.7.0
- golang.org/x/term v0.7.0
- golang.org/x/tools v0.6.0
- golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
- google.golang.org/appengine v1.6.7
- google.golang.org/protobuf v1.28.1
- gopkg.in/yaml.v3 v3.0.1
- gotest.tools/gotestsum v1.8.2