Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::SubtractFunction Struct Reference

Static Public Member Functions

static ScalarFunction GetFunction (const LogicalType &type)
static ScalarFunction GetFunction (const LogicalType &left_type, const LogicalType &right_type)

Member Function Documentation

◆ GetFunction() [1/2]

ScalarFunction duckdb::SubtractFunction::GetFunction ( const LogicalType & type)
static
228826 {
228827 if (type.id() == LogicalTypeId::INTERVAL) {
228828 ScalarFunction func("-", {type}, type, ScalarFunction::UnaryFunction<interval_t, interval_t, NegateOperator>);
228829 func.SetFallible();
228830 return func;
228831 } else if (type.id() == LogicalTypeId::DECIMAL) {
228832 ScalarFunction func("-", {type}, type, nullptr, DecimalNegateBind, nullptr, NegateBindStatistics);
228833 return func;
228834 } else if (type.id() == LogicalTypeId::BIGNUM) {
228835 ScalarFunction func("+", {type}, LogicalType::BIGNUM, BignumNegate);
228836 return func;
228837 } else {
228838 D_ASSERT(type.IsNumeric());
228839 ScalarFunction func("-", {type}, type, ScalarFunction::GetScalarUnaryFunction<NegateOperator>(type), nullptr,
228840 nullptr, NegateBindStatistics);
228841 func.SetFallible();
228842 return func;
228843 }
228844}

◆ GetFunction() [2/2]

ScalarFunction duckdb::SubtractFunction::GetFunction ( const LogicalType & left_type,
const LogicalType & right_type )
static
228846 {
228847 if (left_type.IsNumeric() && left_type.id() == right_type.id()) {
228848 if (left_type.id() == LogicalTypeId::DECIMAL) {
228849 ScalarFunction function("-", {left_type, right_type}, left_type, nullptr,
228850 BindDecimalAddSubtract<SubtractOperator, DecimalSubtractOverflowCheck, true>);
228851 function.SetFallible();
228852 function.SetSerializeCallback(SerializeDecimalArithmetic);
228853 function.SetDeserializeCallback(
228854 DeserializeDecimalArithmetic<SubtractOperator, DecimalSubtractOverflowCheck>);
228855 return function;
228856 } else if (left_type.IsIntegral()) {
228857 ScalarFunction function(
228858 "-", {left_type, right_type}, left_type,
228859 GetScalarIntegerFunction<SubtractOperatorOverflowCheck>(left_type.InternalType()), nullptr, nullptr,
228860 PropagateNumericStats<TrySubtractOperator, SubtractPropagateStatistics, SubtractOperator>);
228861 function.SetFallible();
228862 return function;
228863
228864 } else {
228865 ScalarFunction function("-", {left_type, right_type}, left_type,
228866 GetScalarBinaryFunction<SubtractOperator>(left_type.InternalType()));
228867 function.SetFallible();
228868 return function;
228869 }
228870 }
228871
228872 switch (left_type.id()) {
228873 case LogicalTypeId::BIGNUM: {
228874 ScalarFunction function("-", {left_type, right_type}, left_type, BignumSubtract);
228875 return function;
228876 }
228877 case LogicalTypeId::DATE:
228878 if (right_type.id() == LogicalTypeId::DATE) {
228879 ScalarFunction function("-", {left_type, right_type}, LogicalType::BIGINT,
228880 ScalarFunction::BinaryFunction<date_t, date_t, int64_t, SubtractOperator>);
228881 function.SetFallible();
228882 return function;
228883
228884 } else if (right_type.id() == LogicalTypeId::INTEGER) {
228885 ScalarFunction function("-", {left_type, right_type}, LogicalType::DATE,
228886 ScalarFunction::BinaryFunction<date_t, int32_t, date_t, SubtractOperator>);
228887 function.SetFallible();
228888 return function;
228889 } else if (right_type.id() == LogicalTypeId::INTERVAL) {
228890 ScalarFunction function("-", {left_type, right_type}, LogicalType::TIMESTAMP,
228891 ScalarFunction::BinaryFunction<date_t, interval_t, timestamp_t, SubtractOperator>);
228892 function.SetFallible();
228893 return function;
228894 }
228895 break;
228896 case LogicalTypeId::TIMESTAMP:
228897 if (right_type.id() == LogicalTypeId::TIMESTAMP) {
228898 ScalarFunction function(
228899 "-", {left_type, right_type}, LogicalType::INTERVAL,
228900 ScalarFunction::BinaryFunction<timestamp_t, timestamp_t, interval_t, SubtractOperator>);
228901 function.SetFallible();
228902 return function;
228903 } else if (right_type.id() == LogicalTypeId::INTERVAL) {
228904 ScalarFunction function(
228905 "-", {left_type, right_type}, LogicalType::TIMESTAMP,
228906 ScalarFunction::BinaryFunction<timestamp_t, interval_t, timestamp_t, SubtractOperator>);
228907 function.SetFallible();
228908 return function;
228909 }
228910 break;
228911 case LogicalTypeId::INTERVAL:
228912 if (right_type.id() == LogicalTypeId::INTERVAL) {
228913 ScalarFunction function(
228914 "-", {left_type, right_type}, LogicalType::INTERVAL,
228915 ScalarFunction::BinaryFunction<interval_t, interval_t, interval_t, SubtractOperator>);
228916 function.SetFallible();
228917 return function;
228918 }
228919 break;
228920 case LogicalTypeId::TIME:
228921 if (right_type.id() == LogicalTypeId::INTERVAL) {
228922 ScalarFunction function("-", {left_type, right_type}, LogicalType::TIME,
228923 ScalarFunction::BinaryFunction<dtime_t, interval_t, dtime_t, SubtractTimeOperator>);
228924 function.SetFallible();
228925 return function;
228926 }
228927 break;
228928 case LogicalTypeId::TIME_TZ:
228929 if (right_type.id() == LogicalTypeId::INTERVAL) {
228930 ScalarFunction function(
228931 "-", {left_type, right_type}, LogicalType::TIME_TZ,
228932 ScalarFunction::BinaryFunction<dtime_tz_t, interval_t, dtime_tz_t, SubtractTimeOperator>);
228933 function.SetFallible();
228934 return function;
228935 }
228936 break;
228937 default:
228938 break;
228939 }
228940 // LCOV_EXCL_START
228941 throw NotImplementedException("SubtractFun for types %s, %s", EnumUtil::ToString(left_type.id()),
228942 EnumUtil::ToString(right_type.id()));
228943 // LCOV_EXCL_STOP
228944}

The documentation for this struct was generated from the following file: