Documentation
¶
Overview ¶
Package rowstruct materializes a STRUCT column value for SQL clients: the Go analogue of Java's RowStruct family, where a struct column read off a record surfaces as a RelationalStruct rather than as the raw protobuf message.
Java's chain is RowStruct.getObject → getStruct → `new ImmutableRowStruct(new MessageTuple((Message) obj), metaData.getStructMetaData(col))` (RowStruct.java:184-197, :281-302), with MessageTuple reading the message POSITIONALLY over its descriptor's fields (MessageTuple.java:53-78) and RelationalStructMetaData backed by the struct's DataType (RelationalStructMetaData.java:40-135). This package is the same three pieces: MessageStruct (the struct), its positional accessor over the descriptor, and StructMetaData over an api.StructType.
Index ¶
- type MessageStruct
- type OrdinalStruct
- type StructMetaData
- func (m *StructMetaData) AttributeCount() int
- func (m *StructMetaData) AttributeDataType(oneBasedIndex int) (api.DataType, error)
- func (m *StructMetaData) AttributeName(oneBasedIndex int) (string, error)
- func (m *StructMetaData) AttributeNullable(oneBasedIndex int) (int, error)
- func (m *StructMetaData) AttributeType(oneBasedIndex int) (int, error)
- func (m *StructMetaData) AttributeTypeName(oneBasedIndex int) (string, error)
- func (m *StructMetaData) TypeName() string
- type TypedOrdinalRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageStruct ¶
type MessageStruct struct {
// contains filtered or unexported fields
}
MessageStruct is an api.Struct over a proto message — Java's ImmutableRowStruct wrapping a MessageTuple.
Attributes are read POSITIONALLY off the descriptor, which is Java's contract (MessageTuple.getObject's `descriptor.getFields().get(position)`) and the only sound one: two same-named fields cannot occur in a descriptor, but position is what the metadata's ordinals mean.
func New ¶
func New(msg protoreflect.Message) (*MessageStruct, error)
New builds the struct view of a proto message. The metadata is derived from the message's own descriptor, so a struct read back through it reports the DECLARED struct type name (Java: RelationalStructMetaData .getTypeName, :62-65).
func (*MessageStruct) Attribute ¶
func (s *MessageStruct) Attribute(oneBasedIndex int) (any, error)
Attribute returns the attribute at oneBasedIndex (JDBC convention).
func (*MessageStruct) AttributeByName ¶
func (s *MessageStruct) AttributeByName(name string) (any, error)
AttributeByName looks the attribute up by name, case-insensitively — Java resolves a struct attribute name the same way (RelationalStruct.getOneBasedPosition:156-164, equalsIgnoreCase).
func (*MessageStruct) AttributeCount ¶
func (s *MessageStruct) AttributeCount() int
AttributeCount returns the number of attributes.
func (*MessageStruct) Attributes ¶
func (s *MessageStruct) Attributes() []any
Attributes returns every attribute in declared order. An attribute that cannot be materialized surfaces as nil rather than an error, because the interface has no error channel here; every caller that needs the failure uses Attribute.
func (*MessageStruct) MetaData ¶
func (s *MessageStruct) MetaData() api.StructMetaData
MetaData returns the struct's metadata.
type OrdinalStruct ¶
type OrdinalStruct struct {
// contains filtered or unexported fields
}
OrdinalStruct is the SQL-client view of a record-valued ordinal row. The executor keeps nested records as positional rows so further FieldValues can address them by baked ordinal; the public boundary exposes the same value as api.Struct, just as MessageStruct does for a protobuf-backed record.
func NewOrdinal ¶
func NewOrdinal(row TypedOrdinalRow) (*OrdinalStruct, error)
NewOrdinal validates and wraps one exact positional record. It deliberately has no width/name recovery: a malformed row is an executor bug, not a struct whose missing attributes should quietly read as NULL.
func (*OrdinalStruct) Attribute ¶
func (s *OrdinalStruct) Attribute(oneBasedIndex int) (any, error)
Attribute reads the one-based attribute and recursively materializes nested ordinal/protobuf records and arrays into their public representations.
func (*OrdinalStruct) AttributeByName ¶
func (s *OrdinalStruct) AttributeByName(name string) (any, error)
AttributeByName resolves a unique field case-insensitively. Duplicate exact record labels remain ambiguous; ordinal access is always available.
func (*OrdinalStruct) AttributeCount ¶
func (s *OrdinalStruct) AttributeCount() int
AttributeCount returns the number of positional record fields.
func (*OrdinalStruct) Attributes ¶
func (s *OrdinalStruct) Attributes() []any
Attributes returns all attributes in declared order. As with MessageStruct, the interface has no error channel, so an individually malformed attribute is represented as nil; callers needing the error use Attribute.
func (*OrdinalStruct) MetaData ¶
func (s *OrdinalStruct) MetaData() api.StructMetaData
MetaData returns metadata derived from the exact planner RecordType.
type StructMetaData ¶
type StructMetaData struct {
// contains filtered or unexported fields
}
StructMetaData is api.StructMetaData backed by an api.StructType — Java's RelationalStructMetaData (RelationalStructMetaData.java:40-135).
func NewStructMetaData ¶
func NewStructMetaData(t *api.StructType) *StructMetaData
NewStructMetaData wraps a struct type as struct metadata.
func (*StructMetaData) AttributeCount ¶
func (m *StructMetaData) AttributeCount() int
AttributeCount returns the number of attributes.
func (*StructMetaData) AttributeDataType ¶
func (m *StructMetaData) AttributeDataType(oneBasedIndex int) (api.DataType, error)
AttributeDataType returns the attribute's full DataType.
func (*StructMetaData) AttributeName ¶
func (m *StructMetaData) AttributeName(oneBasedIndex int) (string, error)
AttributeName returns the attribute's declared name.
func (*StructMetaData) AttributeNullable ¶
func (m *StructMetaData) AttributeNullable(oneBasedIndex int) (int, error)
AttributeNullable reports whether the attribute admits NULL.
func (*StructMetaData) AttributeType ¶
func (m *StructMetaData) AttributeType(oneBasedIndex int) (int, error)
AttributeType returns the attribute's JDBC type code.
func (*StructMetaData) AttributeTypeName ¶
func (m *StructMetaData) AttributeTypeName(oneBasedIndex int) (string, error)
AttributeTypeName returns the attribute type's display name.
func (*StructMetaData) TypeName ¶
func (m *StructMetaData) TypeName() string
TypeName returns the declared struct type name.
type TypedOrdinalRow ¶
type TypedOrdinalRow interface {
values.OrdinalRow
OrdinalRecordType() *values.RecordType
OrdinalRowKind() values.OrdinalCarrierKind
}
TypedOrdinalRow is the exact, positional representation accepted by NewOrdinal. executor.PositionalRow implements it without making rowstruct depend on the executor package (which is a higher layer).