package
0.0.0-20241018072137-00ebc30e3b87
Repository: https://github.com/secretflow/scql.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# Functions
AddDate fix gap between mysql and golang api When we execute select date_add('2018-01-31',interval 1 month) in mysql we got 2018-02-28 but in tidb we got 2018-03-03.
AddDuration adds time.Duration a and b if no overflow, otherwise returns error.
AddInt64 adds int64 a and b if no overflow, otherwise returns error.
AddInteger adds uint64 a and int64 b and returns uint64 if no overflow error.
AddUint64 adds uint64 a and b if no overflow, else returns error.
AdjustYear is used for adjusting year and checking its validation.
AggFieldType aggregates field types for a multi-argument function like `IF`, `IFNULL`, `COALESCE` whose return type is determined by the arguments' FieldTypes.
AggregateEvalType aggregates arguments' EvalType of a multi-argument function.
ChangeReverseResultByUpperLowerBound is for expression's reverse evaluation.
CheckFsp checks whether fsp is in valid range.
CloneDatum returns a new copy of the datum.
CloneRow deep copies a Datum slice.
CompareDuration returns an integer comparing the duration x to y.
CompareFloat64 returns an integer comparing the float64 x to y.
CompareInt64 returns an integer comparing the int64 x to y.
CompareString returns an integer comparing the string x to y.
CompareUint64 returns an integer comparing the uint64 x to y.
ConvertDatumToDecimal converts datum to decimal.
ConvertDecimalToUint converts a decimal to a uint by converting it to a string first to avoid float overflow (#10181).
ConvertFloatToInt converts a float64 value to a int value.
ConvertFloatToUint converts a float value to an uint value.
ConvertIntToInt converts an int value to another int value of different precision.
ConvertIntToUint converts an int value to an uint value.
ConvertUintToInt converts an uint value to an int value.
ConvertUintToUint converts an uint value to another uint value of different precision.
CurrentTime returns current time with type tp.
DateDiff calculates number of days between two days.
DateFSP gets fsp from date string.
DateTimeIsOverflow returns if this date is overflow.
DatumsToString converts several datums to formatted string.
DatumsToStrNoErr converts some datums to a formatted string.
DecimalAdd adds two decimals, sets the result to 'to'.
DecimalBinSize returns the size of array to hold a binary representation of a decimal.
DecimalDiv does division of two decimals.
DecimalMod does modulus of two decimals.
DecimalMul multiplies two decimals.
DecimalNeg reverses decimal's sign.
DecimalPeak returns the length of the encoded decimal.
DecimalSub subs one decimal from another, sets the result to 'to'.
DefaultCharsetForType returns the default charset/collation for mysql type.
DefaultParamTypeForValue returns the default FieldType for the parameterized value.
DefaultTypeForValue returns the default FieldType for the value.
DivInt64 divides int64 a with b, returns int64 if no overflow error.
DivIntWithUint divides int64 a with uint64 b, returns uint64 if no overflow error.
DivUintWithInt divides uint64 a with int64 b, returns uint64 if no overflow error.
EqualDatums compare if a and b contains the same datum values.
EstimatedMemUsage returns the estimated bytes consumed of a one-dimensional or two-dimensional datum array.
ExtractDatetimeNum extracts time value number from datetime unit and format.
ExtractDurationNum extracts duration value number from duration unit and format.
ExtractDurationValue extract the value from format to Duration.
FormatIntWidthN uses to format int with width.
FromDate makes a internal time representation from the given date.
FromGoTime translates time.Time to mysql time internal representation.
GetFormatType checks the type(Duration, Date or Datetime) of a format string.
GetFracIndex finds the last '.' for get fracStr, index = -1 means fracStr not found.
GetFsp gets the fsp of a string.
GetLastDay returns the last day of the month.
GetMaxFloat gets the max float for given flen and decimal.
GetMaxValue returns the max value datum for each type.
GetMinValue returns the min value datum for each type.
IntergerSignedLowerBound indicates the min int64 values of different mysql types.
IntergerSignedUpperBound indicates the max int64 values of different mysql types.
IntergerUnsignedUpperBound indicates the max uint64 values of different mysql types.
InvOp2 returns an invalid operation error.
IsBinaryStr returns a boolean indicating whether the field type is a binary string type.
IsClockUnit returns true when unit is interval unit with hour, minute or second.
IsDateFormat returns true when the specified time format could contain only date.
IsNonBinaryStr returns a boolean indicating whether the field type is a non-binary string type.
IsString returns a boolean indicating whether the field type is a string type.
IsTemporalWithDate returns a boolean indicating whether the tp is time type with date.
IsTypeFractionable returns a boolean indicating whether the tp can has time fraction.
IsTypeNumeric returns a boolean indicating whether the tp is numeric type.
IsTypePrefixable returns a boolean indicating whether an index on a column with the tp can be defined with a prefix.
IsTypeTemporal checks if a type is a temporal type.
IsTypeTime returns a boolean indicating whether the tp is time type like datetime, date or timestamp.
IsTypeUnspecified returns a boolean indicating whether the tp is the Unspecified type.
IsTypeVarchar returns a boolean indicating whether the tp is the varchar type like a varstring type or a varchar type.
KindStr converts kind to a string.
MakeDatums creates datum slice from interfaces.
MaxMySQLTime returns Duration with maximum mysql time.
MaxValueDatum returns a datum represents max value.
MergeFieldType merges two MySQL type to a new type.
MinNotNullDatum returns a datum represents minimum not null value.
MulInt64 multiplies int64 a and b and returns int64 if no overflow error.
MulInteger multiplies uint64 a and int64 b, and returns uint64 if no overflow error.
MulUint64 multiplies uint64 a and b and returns uint64 if no overflow error.
NewBinaryLiteralDatum creates a new BinaryLiteral Datum for a BinaryLiteral value.
NewBinaryLiteralFromUint creates a new BinaryLiteral instance by the given uint value in BitEndian.
NewBitLiteral parses bit string as BitLiteral type.
NewBytesDatum creates a new Datum from a byte slice.
NewDatum creates a new Datum from an interface{}.
NewDecFromFloatForTest creates a MyDecimal from float, as it returns no error, it should only be used in test.
NewDecFromInt creates a MyDecimal from int.
NewDecFromStringForTest creates a MyDecimal from string, as it returns no error, it should only be used in test.
NewDecFromUint creates a MyDecimal from uint.
NewDecimalDatum creates a new Datum form a MyDecimal value.
NewDuration construct duration with time.
NewDurationDatum creates a new Datum from a Duration value.
NewFieldType returns a FieldType, with a type and other information about field type.
NewFloat32Datum creates a new Datum from a float32 value.
NewFloat64Datum creates a new Datum from a float64 value.
NewHexLiteral parses hexadecimal string as HexLiteral type.
NewIntDatum creates a new Datum from an int64 value.
NewMaxOrMinDec returns the max or min value decimal for given precision and fraction.
NewMysqlBitDatum creates a new MysqlBit Datum for a BinaryLiteral value.
NewStringDatum creates a new Datum from a string.
NewTime constructs time from core time, type and fsp.
NewTimeDatum creates a new Time from a Time value.
NewUintDatum creates a new Datum from an uint64 value.
ParseBitStr parses bit string.
ParseDate is a helper function wrapping ParseTime with date type.
ParseDateFormat parses a formatted date string and returns separated components.
ParseDateFromNum is a helper function wrapping ParseTimeFromNum with date type.
ParseDatetime is a helper function wrapping ParseTime with datetime type and default fsp.
ParseDatetimeFromNum is a helper function wrapping ParseTimeFromNum with datetime type and default fsp.
ParseDuration parses the time form a formatted string with a fractional seconds part, returns the duration type Time value.
ParseDurationValue parses time value from time unit and format.
ParseFrac parses the input string according to fsp, returns the microsecond, and also a bool value to indice overflow.
ParseHexStr parses hexadecimal string literal.
ParseTime parses a formatted string with type tp and specific fsp.
ParseTimeFromFloatString is similar to ParseTime, except that it's used to parse a float converted string.
ParseTimeFromInt64 parses mysql time value from int64.
ParseTimeFromNum parses a formatted int64, returns the value which type is tp.
ParseTimestamp is a helper function wrapping ParseTime with timestamp type and default fsp.
ParseTimestampFromNum is a helper function wrapping ParseTimeFromNum with timestamp type and default fsp.
ParseYear parses a formatted string and returns a year number.
ProduceDecWithSpecifiedTp produces a new decimal according to `flen` and `decimal`.
ProduceFloatWithSpecifiedTp produces a new float64 according to `flen` and `decimal`.
ProduceStrWithSpecifiedTp produces a new string according to `flen` and `chs`.
Round rounds the argument f to dec decimal places.
RoundFloat rounds float val to the nearest integer value with float64 format, like MySQL Round function.
RoundFrac rounds fractional seconds precision with new fsp and returns a new one.
SetBinChsClnFlag sets charset, collation as 'binary' and adds binaryFlag to FieldType.
StrToFloat converts a string to a float64 at the best-effort.
StrToInt converts a string to an integer at the best-effort.
StrToUint converts a string to an unsigned integer at the best-effortt.
SubDuration subtracts time.Duration a with b and returns time.Duration if no overflow error.
SubInt64 subtracts int64 a with b and returns int64 if no overflow error.
SubIntWithUint subtracts int64 a with uint64 b and returns uint64 if no overflow error.
SubUint64 subtracts uint64 a with b and returns uint64 if no overflow error.
SubUintWithInt subtracts uint64 a with int64 b and returns uint64 if no overflow error.
TimeFromDays Converts a day number to a date.
TimestampDiff returns t2 - t1 where t1 and t2 are date or datetime expressions.
ToString converts an interface to a string.
Truncate truncates the argument f to dec decimal places.
TruncateFloat tries to truncate f.
TruncateFrac truncates fractional seconds precision with new fsp and returns a new one.
TruncateOverflowMySQLTime truncates d when it overflows, and returns ErrTruncatedWrongVal.
VecCompareII returns []int64 comparing the []int64 x to []int64 y.
VecCompareIU returns []int64 comparing the []int64 x to []uint64y.
VecCompareUI returns []int64 comparing the []uint64 x to []int64y.
VecCompareUU returns []int64 comparing the []uint64 x to []uint64 y.
# Constants
Ceiling means rounding up.
Time format without fractional seconds precision.
const strings for ErrWrongValue.
DayHourMaxCnt is max parameters count 'DAYS HOURS' expr Format allowed.
DayIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
DayMicrosecondMaxCnt is max parameters count 'DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format allowed.
DayMinuteMaxCnt is max parameters count 'DAYS HOURS:MINUTES' expr Format allowed.
DaySecondMaxCnt is max parameters count 'DAYS HOURS:MINUTES:SECONDS' expr Format allowed.
DefaultFsp is the default digit of fractional seconds part.
constant values.
ETDatetime represents type DATETIME in evaluation.
ETDecimal represents type DECIMAL in evaluation.
ETDuration represents type DURATION in evaluation.
ETInt represents type INT in evaluation.
ETJson represents type JSON in evaluation.
ETReal represents type REAL in evaluation.
ETString represents type STRING in evaluation.
ETTimestamp represents type TIMESTAMP in evaluation.
Floor means rounding down.
GoDurationDay is the gotime.Duration which equals to a Day.
GoDurationWeek is the gotime.Duration which equals to a Week.
HourIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
HourMicrosecondMaxCnt is max parameters count 'HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format allowed.
HourMinuteMaxCnt is max parameters count 'HOURS:MINUTES' expr Format allowed.
HourSecondMaxCnt is max parameters count 'HOURS:MINUTES:SECONDS' expr Format allowed.
Used for BIT / HEX literals.
Kind constants.
Kind constants.
Kind constants.
Kind constants.
Kind constants.
Kind constants.
Kind constants.
Used for BIT table column values.
Kind constants.
Kind constants.
KindMysqlSet byte = 12 // not supported by scql.
Kind constants.
Kind constants.
Kind constants.
Kind constants.
MaxDuration is the maximum for duration.
MaxFsp is the maximum digit of fractional seconds part.
MaxTime is the maximum for mysql time type.
MaxYear is the maximum for mysql year type.
MicrosecondIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
MinFsp is the minimum digit of fractional seconds part.
MinTime is the minimum for mysql time type.
MinuteIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
MinuteMicrosecondMaxCnt is max parameters count 'MINUTES:SECONDS.MICROSECONDS' expr Format allowed.
MinuteSecondMaxCnt is max parameters count 'MINUTES:SECONDS' expr Format allowed.
MinYear is the minimum for mysql year type.
ModeHalfEven rounds normally.
Truncate just truncates the decimal.
MonthIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
MyDecimalStructSize is the struct size of MyDecimal.
SecondIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
SecondMicrosecondMaxCnt is max parameters count 'SECONDS.MICROSECONDS' expr Format allowed.
Time format without fractional seconds precision.
TimeFSPFormat is time format with fractional seconds precision.
TimeMaxHour is the max hour for mysql time type.
TimeMaxMinute is the max minute for mysql time type.
TimeMaxSecond is the max second for mysql time type.
TimeMaxValue is the maximum value for mysql time type.
TimeMaxValueSeconds is the maximum second value for mysql time type.
const strings for ErrWrongValue.
TimeValueCnt is parameters count 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
UnspecifiedFsp is the unspecified fractional seconds part.
UnspecifiedLength is unspecified length.
VarStorageLen indicates this column is a variable length column.
YearIndex is index of 'YEARS-MONTHS DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' expr Format.
YearMonthMaxCnt is max parameters count 'YEARS-MONTHS' expr Format allowed.
ZeroDateStr is the string representation of a zero date.
ZeroDatetimeStr is the string representation of a zero datetime.
# Variables
BoundTimezone is the timezone for min and max timestamp.
EmptyName is to occupy the position in the name slice.
ErrBadNumber is return when parsing an invalid binary decimal number.
ErrCastAsSignedOverflow is returned when positive out-of-range integer, and convert to it's negative complement.
ErrCastNegIntAsUnsigned is returned when a negative integer be casted to an unsigned int.
ErrDataTooLong is returned when converts a string value that is longer than field type length.
ErrDatetimeFunctionOverflow is returned when the calculation in datetime function cause overflow.
ErrDivByZero is return when do division by 0.
ErrDuplicatedValueInType is returned when enum column has duplicated value.
ErrIllegalValueForType is returned when value of type is illegal.
ErrInvalidDefault is returned when meet a invalid default value.
ErrInvalidFieldSize is returned when the precision of a column is out of range.
ErrInvalidWeekModeFormat is returned when the week mode is wrong.
ErrInvalidYear is returned when the input value is not a valid year.
ErrInvalidYearFormat is returned when the input is not a valid year format.
ErrMBiggerThanD is returned when precision less than the scale.
ErrOverflow is returned when data is out of range for a field type.
ErrTooBigDisplayWidth is return when display width out of range for column.
ErrTooBigFieldLength is return when column length too big for column.
ErrTooBigPrecision is returned when type DECIMAL/NUMERIC precision is bigger than mysql.MaxDecimalWidth.
ErrTooBigScale is returned when type DECIMAL/NUMERIC scale is bigger than mysql.MaxDecimalScale.
ErrTooBigSet is returned when too many strings for column.
ErrTruncated is returned when data has been truncated during conversion.
ErrTruncatedWrongVal is returned when data has been truncated during conversion.
ErrWarnDataOutOfRange is returned when the value in a numeric column that is outside the permissible range of the column data type.
ErrWrongValue is returned when the input value is in wrong format.
ErrWrongValueForType is returned when the input value is in wrong format for function.
IsTypeBlob returns a boolean indicating whether the tp is a blob type.
IsTypeChar returns a boolean indicating whether the tp is the char type like a string type or a varchar type.
MaxDatetime is the maximum for mysql datetime type.
MaxTimestamp is the maximum for mysql timestamp type.
MinDatetime is the minimum for mysql datetime type.
MinTimestamp is the minimum for mysql timestamp type.
MonthNames lists names of months, which are used in builtin time function `monthname`.
TypeStr converts tp to a string.
TypeToStr converts a field to a string.
WeekdayNames lists names of weekdays, which are used in builtin time function `dayname`.
ZeroBinaryLiteral is a BinaryLiteral literal with zero value.
ZeroCoreTime is the zero value for TimeInternal type.
ZeroDate is the zero value for date Time.
ZeroDatetime is the zero value for datetime Time.
ZeroDuration is the zero value for Duration type.
ZeroCoreTime is the zero value for Time type.
ZeroTimestamp is the zero value for timestamp Time.
# Structs
Datum is a data box holds different kind of data.
Duration is the type for MySQL TIME type.
FieldName records the names used for mysql protocol.
MyDecimal represents a decimal value.
MysqlTime is the internal struct type for Time.
Time is the struct for handling datetime, timestamp and date.
# Type aliases
BinaryLiteral is the internal type for storing bit / hex literal type.
BitLiteral is the bit literal type.
EvalType indicates the specified types that arguments and result of a built-in function should be.
FieldType records field type information.
HexLiteral is the hex literal type.
NameSlice is the slice of the *fieldName.
RoundingType is used to indicate the rounding type for reversing evaluation.
RoundMode is the type for round mode.