qvalue

package
v0.0.0-...-a1fdb8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToAvroCompatibleName

func ConvertToAvroCompatibleName(columnName string) string

ConvertToAvroCompatibleName converts a column name to a field name that is compatible with Avro.

func DefaultTime

func DefaultTime(dwh protos.DBType) time.Time

func DetermineNumericSettingForDWH

func DetermineNumericSettingForDWH(precision int16, scale int16, dwh protos.DBType) (int16, int16)

func Equals

func Equals(qv types.QValue, other types.QValue) bool

func GetAvroSchemaFromQValueKind

func GetAvroSchemaFromQValueKind(
	ctx context.Context,
	env map[string]string,
	kind types.QValueKind,
	targetDWH protos.DBType,
	precision int16,
	scale int16,
) (avro.Schema, error)

GetAvroSchemaFromQValueKind returns the Avro schema for a given QValueKind. The function takes in two parameters, a QValueKind and a boolean indicating if the Avro schema should respect null values. It returns a QValueKindAvroSchema object representing the Avro schema and an error if the QValueKind is unsupported.

For example, QValueKindInt64 would return an AvroLogicalSchema of "long". Unsupported QValueKinds will return an error.

func NullableAvroSchema

func NullableAvroSchema(schema avro.Schema) (avro.Schema, error)

func QValueToAvro

func QValueToAvro(
	ctx context.Context,
	value types.QValue, field *types.QField, targetDWH protos.DBType, logger log.Logger,
	unboundedNumericAsString bool, stat *NumericStat,
	binaryFormat internal.BinaryFormat,
	calcSize bool,
) (any, int64, error)

func ShouldUseNativeJSONType

func ShouldUseNativeJSONType(ctx context.Context, env map[string]string, chVersion *chproto.Version) bool

func ToDWHColumnType

func ToDWHColumnType(
	ctx context.Context,
	kind types.QValueKind,
	env map[string]string,
	dwhType protos.DBType,
	dwhVersion *chproto.Version,
	column *protos.FieldDescription,
	nullableEnabled bool,
	flags []string,
) (string, error)

func TruncateNumeric

func TruncateNumeric(
	num decimal.Decimal, targetPrecision, targetScale int16, targetDWH protos.DBType, stat *NumericStat,
) (decimal.Decimal, int, bool)

TruncateNumeric truncates a decimal to fit within the target precision and scale. Returns the truncated decimal, the number of integer digits, and whether truncation succeeded. If ok is false, the value was too large and should be treated as zero.

Types

type NumericDestinationType

type NumericDestinationType struct {
	IsString         bool
	Precision, Scale int16
}

func GetNumericDestinationType

func GetNumericDestinationType(
	precision, scale int16, targetDWH protos.DBType, unboundedNumericAsString bool,
) NumericDestinationType

type NumericStat

type NumericStat struct {
	DestinationTable         string
	DestinationColumn        string
	TruncatedCount           uint64
	MaxExponent              int32
	LongIntegersClearedCount uint64
	MaxIntegerDigits         int32
	BigInt256ClearedCount    uint64
}

func NewNumericStat

func NewNumericStat(destinationTable, destinationColumn string) NumericStat

func (*NumericStat) CollectWarnings

func (ns *NumericStat) CollectWarnings(warnings *shared.QRepWarnings)

type QValueAvroConverter

type QValueAvroConverter struct {
	*types.QField

	Stat                     *NumericStat
	TargetDWH                protos.DBType
	UnboundedNumericAsString bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL