Documentation
¶
Index ¶
- Variables
- type ClosedEvent
- type Column
- type ColumnResult
- type ConnectedEvent
- type Duration
- type Error
- type ErrorEvent
- type ErrorResponse
- type ErrorResult
- type Event
- type NormalizedError
- type NormalizedErrorResponse
- type Output
- type OutputCompression
- type OutputDestination
- type OutputFormat
- type Outputs
- type QueryStatus
- type Result
- type RowResult
- type SessionStatus
- type StatusResult
- type SuccessResult
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ClosedEvent ¶
type ClosedEvent struct {
Status SessionStatus `json:"status"`
// contains filtered or unexported fields
}
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Length int64 `json:"length,omitempty"`
Precision int64 `json:"precision,omitempty"`
Scale int64 `json:"scale,omitempty"`
Object bool `json:"isObject,omitempty"`
Numeric bool `json:"isNumeric,omitempty"`
// TODO: Remove from public interface.
ScanType reflect.Type `json:"-"`
}
Column represents a column in a result set. It includes the name and type of the column, and can also include additional information about the column type, such as the length, precision, and scale - e.g. for a VARCHAR(10) or NUMERIC(5, 3) column type. NOTE: The ScanType field specifies the Go type that column values will be scanned into, but is only used internally - it should not be considered part of the public interface, and may be removed in the future.
type ColumnResult ¶
type ColumnResult struct {
RunID uuid.UUID `json:"runId"`
Columns []Column `json:"columns"`
// contains filtered or unexported fields
}
ColumnResult is the first Result type streamed back in the results (besides potential StatusResult messages), assuming there wasn't an error. It includes information about the result columns being returned, including their names and types. It also includes the run ID.
type ConnectedEvent ¶
type ConnectedEvent struct {
Status SessionStatus `json:"status"`
// contains filtered or unexported fields
}
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a wrapper around time.Duration that allows it to be marshalled to/from JSON via the standard duration string format.
func NewDuration ¶
NewDuration returns a new Duration initialized with the provided time.Duration value.
func NewDurationPtr ¶
NewDuration returns a pointer to a new Duration initialized with the provided time.Duration value. Returns nil if the provided time.Duration is nil.
func (Duration) MarshalJSON ¶
Implements the json.Marshaler interface.
type Error ¶
type Error struct {
Message string `json:"message"`
}
Error represents the error field of an ErrorResponse.
type ErrorEvent ¶
type ErrorEvent struct {
Status SessionStatus `json:"status"`
Error *NormalizedError `json:"error"`
// contains filtered or unexported fields
}
type ErrorResponse ¶
ErrorResponse represents the structure of an error response body as returned from one of the API endpoints.
func NewErrorResponse ¶
func NewErrorResponse(err error) ErrorResponse
NewErrorResponse constructs a new ErrorResponse from the provided Error.
type ErrorResult ¶
type ErrorResult struct {
Success bool `json:"success"`
RowCount int `json:"rowCount"`
Elapsed Duration `json:"elapsed"`
Error *NormalizedError `json:"error"`
// contains filtered or unexported fields
}
ErrorResult is the final Result type returned if there was an error executing the query. Its fields are a superset of NormalizedErrorResponse. It can be returned at any point, so long as SuccessResult was not yet returned - i.e. it can be the first Result returned, or it can be returned after some number of RowResult values have already been returned.
type Event ¶
type Event interface {
// contains filtered or unexported methods
}
Event is an interface representing the types that are streamed back from the GET /user/:userID/session/sessionID/events endpoint. The isEvent method is a no-op that gives us compile-time assurance that only the event types defined below implement the interface.,
type NormalizedError ¶
type NormalizedError struct {
Code string `json:"code,omitempty"`
Column int32 `json:"column,omitempty"`
Detail string `json:"detail,omitempty"`
Hint string `json:"hint,omitempty"`
Line int32 `json:"line,omitempty"`
Message string `json:"message"`
Position int32 `json:"position,omitempty"`
// The name of the client.
Source string `json:"source"`
// Connect indicates that the error occurred while connecting to the
// database.
Connect bool `json:"connect,omitempty"`
// Fatal indicates whether the underlying session/connection is broken.
Fatal bool `json:"fatal,omitempty"`
// Timeout indicates whether the run timed out.
Timeout bool `json:"timeout,omitempty"`
// Cancel indicates whether the run was canceled.
Cancel bool `json:"cancel,omitempty"`
}
NormalizedError represents an error returned from the underlying database. It includes a variety of optional fields which are populated depending on the underlying database driver implementation. Only the source and message fields are guaranteed to be present.
func (*NormalizedError) Error ¶
func (e *NormalizedError) Error() string
Error implements the error interface.
type NormalizedErrorResponse ¶
type NormalizedErrorResponse struct {
Error *NormalizedError `json:"error"`
Success bool `json:"success"`
}
NormalizedErrorResponse represents the structure of an error response body as returned from one of the API endpoints when the error is a NormalizedError. Because the fields of NormalizedError are a superset of the Error fields, the response structure is compatible with ErrorResponse.
func NewNormalizedErrorResponse ¶
func NewNormalizedErrorResponse(err *NormalizedError) NormalizedErrorResponse
NewNormalizedErrorResponse constructs a new NormalizedErrorResponse from the provided NormalizedError.
type Output ¶
type Output struct {
Format OutputFormat `json:"format"`
Destination OutputDestination `json:"destination"`
Compression OutputCompression `json:"compression,omitempty"`
RowNum bool `json:"rowNum,omitempty"`
Limit int64 `json:"limit,omitempty"`
// For CSV/TSV formats.
NullValue string `json:"nullValue,omitempty"`
// For file destination.
Path string `json:"path,omitempty"`
}
Output represents a request to write run results to a specific destination (e.g. the results endpoint or the local filesystem) in a specific format (e.g. Arrow IPC Streaming/File Format, Parquet, CSV, or TSV). It also specifies whether gzip compression should be used, and whether the special __popsql_row_num__ field should be included in the results.
type OutputCompression ¶
type OutputCompression string
OutputCompression represents the supported types of compression that can be applied to run results before they are written to a destination.
const ( OutputCompressionNone OutputCompression = "" OutputCompressionBrotli OutputCompression = "brotli" OutputCompressionGzip OutputCompression = "gzip" OutputCompressionLZ4 OutputCompression = "lz4" OutputCompressionSnappy OutputCompression = "snappy" OutputCompressionZstd OutputCompression = "zstd" )
type OutputDestination ¶
type OutputDestination string
OutputDestination represents the supported destinations that run results can be written to.
const ( OutputDestinationEndpoint OutputDestination = "endpoint" OutputDestinationFile OutputDestination = "file" )
type OutputFormat ¶
type OutputFormat string
OutputFormat represents the supported formats that run results can be written to.
const ( OutputFormatArrowStream OutputFormat = "arrowStream" OutputFormatArrowFile OutputFormat = "arrowFile" OutputFormatParquet OutputFormat = "parquet" OutputFormatCSV OutputFormat = "csv" OutputFormatTSV OutputFormat = "tsv" OutputFormatJSON OutputFormat = "json" )
type QueryStatus ¶
type QueryStatus string
QueryStatus represents a query status value, as returned in a StatusResult.
const (
StatusPending QueryStatus = "pending"
)
Valid QueryStatus values.
type Result ¶
type Result interface {
// contains filtered or unexported methods
}
Result is an interface representing the types that are streamed back from the GET /run and GET /session/:sessionID/run endpoints. The isResult method is a no-op that gives us compile-time assurance that only the result types defined below implement the interface.,
type RowResult ¶
type RowResult struct {
Row []any `json:"row,omitempty"`
// contains filtered or unexported fields
}
RowResult is the Result type returned after ColumnResult, assuming there wasn't an error, and the query is returning at least one row. One RowResult will be returned for each row in the result set.
type SessionStatus ¶
type SessionStatus string
Status represents a session status value, as returned in a [StatusEvent].
const ( StatusConnected SessionStatus = "connected" StatusClosed SessionStatus = "closed" StatusError SessionStatus = "error" )
Valid SessionStatus values.
type StatusResult ¶
type StatusResult struct {
Status QueryStatus `json:"status"`
// contains filtered or unexported fields
}
StatusResult is a Result type that is returned every so often when the query is in progress, but no other Result types have been returned for awhile. Its primary purpose is to keep the underlying TCP connection active, to avoid idle connection timeouts that would otherwise forcibly close the connection (such as the AWS Application Load Balancer idle connection timeout). See: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout).
type SuccessResult ¶
type SuccessResult struct {
Success bool `json:"success"`
RowCount int `json:"rowCount"`
RowsAffected *int64 `json:"rowsAffected,omitempty"`
Elapsed Duration `json:"elapsed"`
// contains filtered or unexported fields
}
SuccessResult is the final Result type returned if the query was successful. It is returned after all RowResult values have been returned, and includes the total row count as well as the overall elapsed query execution duration. It also returns the number of rows affected, if supported by the underlying driver.