func toSubstraitLiteral()

in table/substrait/substrait.go [246:280]


func toSubstraitLiteral(typ iceberg.Type, lit iceberg.Literal) expr.Literal {
	switch lit := lit.(type) {
	case iceberg.BoolLiteral:
		return toPrimitiveSubstraitLiteral(bool(lit))
	case iceberg.Int32Literal:
		return toPrimitiveSubstraitLiteral(int32(lit))
	case iceberg.Int64Literal:
		return toPrimitiveSubstraitLiteral(int64(lit))
	case iceberg.Float32Literal:
		return toPrimitiveSubstraitLiteral(float32(lit))
	case iceberg.Float64Literal:
		return toPrimitiveSubstraitLiteral(float64(lit))
	case iceberg.StringLiteral:
		return toPrimitiveSubstraitLiteral(string(lit))
	case iceberg.TimestampLiteral:
		if typ.Equals(iceberg.PrimitiveTypes.TimestampTz) {
			return toPrimitiveSubstraitLiteral(types.TimestampTz(lit))
		}

		return toPrimitiveSubstraitLiteral(types.Timestamp(lit))
	case iceberg.DateLiteral:
		return toPrimitiveSubstraitLiteral(types.Date(lit))
	case iceberg.TimeLiteral:
		return toPrimitiveSubstraitLiteral(types.Time(lit))
	case iceberg.BinaryLiteral:
		return toByteSliceSubstraitLiteral([]byte(lit))
	case iceberg.FixedLiteral:
		return toFixedLiteral(lit)
	case iceberg.UUIDLiteral:
		return toByteSliceSubstraitLiteral(types.UUID(lit[:]))
	case iceberg.DecimalLiteral:
		return toDecimalLiteral(lit)
	}
	panic(fmt.Errorf("invalid literal type: %s", lit.Type()))
}