package utility

import "cloud.google.com/go/spanner/test/cloudexecutor/executor/internal/utility"

Index

Functions

func BuildQuery

func BuildQuery(queryAction *executorpb.QueryAction) (spanner.Statement, error)

BuildQuery constructs a spanner.Statement query and bind the params from the input executorpb.QueryAction.

func ConvertSpannerRow

func ConvertSpannerRow(row *spanner.Row) (*executorpb.ValueList, *sppb.StructType, error)

ConvertSpannerRow takes a Cloud Spanner Row and translates it to executorpb.ValueList and sppb.StructType. The result is always a struct, in which each value corresponds to a column of the Row.

func ErrToStatus

func ErrToStatus(e error) *spb.Status

ErrToStatus maps cloud error to Status

func ExecutorValueToSpannerValue

func ExecutorValueToSpannerValue(t *spannerpb.Type, v *executorpb.Value, null bool) (any, error)

ExecutorValueToSpannerValue converts executorpb.Value with given spannerpb.Type into a cloud spanner interface. Parameter null indicates whether this value is NULL.

func KeySetProtoToCloudKeySet

func KeySetProtoToCloudKeySet(keySetProto *executorpb.KeySet, typeList []*spannerpb.Type) (spanner.KeySet, error)

KeySetProtoToCloudKeySet converts executorpb.KeySet to spanner.KeySet.

Types

type TableMetadataHelper

type TableMetadataHelper struct {
	// contains filtered or unexported fields
}

TableMetadataHelper is used to hold and retrieve metadata of tables and columns involved in a transaction.

func (*TableMetadataHelper) GetColumnType

func (t *TableMetadataHelper) GetColumnType(tableName string, colName string) (*spannerpb.Type, error)

GetColumnType returns the column type of the given table and column.

func (*TableMetadataHelper) GetKeyColumnTypes

func (t *TableMetadataHelper) GetKeyColumnTypes(tableName string) ([]*spannerpb.Type, error)

GetKeyColumnTypes returns a list of key column types of the given table.

func (*TableMetadataHelper) InitFrom

InitFrom reads table metadata from the given StartTransactionAction.

func (*TableMetadataHelper) InitFromTableMetadata

func (t *TableMetadataHelper) InitFromTableMetadata(tables []*executorpb.TableMetadata)

InitFromTableMetadata extracts table metadata and make maps to store them.

Source Files

error_code_mapper.go executor_to_spanner_value_converter.go key.go spanner_to_executor_value_converter.go table_metadata_helper.go

Version
v1.76.1 (latest)
Published
Feb 21, 2025
Platform
linux/amd64
Imports
17 packages
Last checked
14 hours ago

Tools for package owners.