Skip to content

Commit 674376c

Browse files
authored
docs: code and feature clarifications (#156)
1 parent b96ca33 commit 674376c

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

expr/literals.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type nestedLiteral interface {
3434
}
3535

3636
type WithTypeLiteral interface {
37+
// WithType attempts to convert a literal to a new type while preserving its value
3738
WithType(types.Type) (Literal, error)
3839
}
3940

@@ -97,7 +98,7 @@ type Literal interface {
9798
ValueString() string
9899
}
99100

100-
// A NullLiteral is a typed null, so it just contains its type
101+
// A NullLiteral is a typed null, so it just contains its type with no value
101102
type NullLiteral struct {
102103
Type types.Type
103104
}
@@ -768,6 +769,7 @@ func getNullability(nullable bool) types.Nullability {
768769
return types.NullabilityRequired
769770
}
770771

772+
// A PrimitiveLiteral is a literal with one of the types specified in this interface
771773
type newPrimitiveLiteralTypes interface {
772774
bool | int8 | int16 | ~int32 | ~int64 |
773775
float32 | float64 | string

extensions/simple_extension.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type TypeVariation struct {
5757
Functions TypeVariationFunctions
5858
}
5959

60+
// FuncParameter is an argument of a function in its function definition
6061
type FuncParameter interface {
6162
toTypeString() string
6263
argumentMarker() // unexported marker method

extensions/variants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type FunctionVariant interface {
1919
Args() FuncParameterList
2020
Options() map[string]Option
2121
URI() string
22+
// ResolveType computes the return type of a function variant, given the input argument types
2223
ResolveType(argTypes []types.Type, registry Set) (types.Type, error)
2324
Variadic() *VariadicBehavior
2425
// Match this function matches input arguments against this functions parameter list

literal/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
proto "github.com/substrait-io/substrait-protobuf/go/substraitpb"
1515
)
1616

17+
//This package contains utility functions for creating literals
18+
1719
func NewBool(value bool, nullable bool) expr.Literal {
1820
return expr.NewPrimitiveLiteral(value, nullable)
1921
}

types/types.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ type (
408408
// FuncArg corresponds to the protobuf FunctionArgument. Anything
409409
// which could be a function argument should meet this interface.
410410
// This is either an Expression, a Type, or an Enum (string).
411+
// These are the actual arguments for a function present in a plan.
411412
FuncArg interface {
412413
fmt.Stringer
413414
ToProtoFuncArg() *proto.FunctionArgument
@@ -419,7 +420,7 @@ type (
419420
}
420421

421422
// Type corresponds to the proto.Type message and represents
422-
// a specific type. These are types which can be present in plan (are serializable)
423+
// a specific concrete type. These are types which can be present in plan (are serializable)
423424
Type interface {
424425
FuncArg
425426
isRootRef()
@@ -469,8 +470,9 @@ type (
469470
BaseString() string
470471
}
471472

472-
// FuncDefArgType this represents a type used in function argument
473-
// These type can't be present in plan (not serializable)
473+
// FuncDefArgType represents a type used in a function argument
474+
// This is an unresolved type of an argument present in the function definition.
475+
// This type can't be present in plan (not serializable)
474476
FuncDefArgType interface {
475477
fmt.Stringer
476478
//SetNullability set nullability as given argument
@@ -913,6 +915,11 @@ func (s *PrimitiveType[T]) WithParameters([]interface{}) (Type, error) {
913915
}
914916

915917
// create type aliases to the generic structs
918+
//
919+
// The parameterized types below use parameterizedTypeSingleIntegerParam to
920+
// create types that accept a single integer parameter (e.g., precision)
921+
// Other parameterized types (e.g. DecimalType) have their
922+
// own dedicated type definitions (ParameterizedDecimalType) rather than using the generic parameterized type.
916923
type (
917924
BooleanType = PrimitiveType[bool]
918925
Int8Type = PrimitiveType[int8]

0 commit comments

Comments
 (0)