Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Jul 4, 2024
1 parent ba8621e commit de9d83f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions velox/functions/lib/aggregates/MinMaxAggregateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ template <>
const double MinAggregate<double>::kInitialValue_ =
MinMaxTrait<double>::quiet_NaN();

// Spark requires timestamp data precision to be in microseconds. Add this class
// to align with Spark's behavior.
class TimestampMicrosPrecisionMaxAggregate : public MaxAggregate<Timestamp> {
public:
explicit TimestampMicrosPrecisionMaxAggregate(TypePtr resultType)
Expand All @@ -301,6 +303,8 @@ class TimestampMicrosPrecisionMaxAggregate : public MaxAggregate<Timestamp> {
}
};

// Spark requires timestamp data precision to be in microseconds. Add this class
// to align with Spark's behavior.
class TimestampMicrosPrecisionMinAggregate : public MinAggregate<Timestamp> {
public:
explicit TimestampMicrosPrecisionMinAggregate(TypePtr resultType)
Expand Down
12 changes: 10 additions & 2 deletions velox/functions/prestosql/aggregates/MinMaxAggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,18 @@ exec::AggregateRegistrationResult registerMinMax(
}
} else {
if (registerMin) {
auto factory = getMinFunctionFactory(name, false, true, true);
auto factory = getMinFunctionFactory(
name,
false /*nestedNullAllowed*/,
true /*mapTypeSupported*/,
true /*useMillisPrecision*/);
return factory(step, argTypes, resultType, config);
} else {
auto factory = getMaxFunctionFactory(name, false, true, true);
auto factory = getMaxFunctionFactory(
name,
false /*nestedNullAllowed*/,
true /*mapTypeSupported*/,
true /*useMillisPrecision*/);
return factory(step, argTypes, resultType, config);
}
}
Expand Down
8 changes: 7 additions & 1 deletion velox/functions/sparksql/aggregates/MinMaxAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "velox/functions/lib/aggregates/MinMaxAggregateBase.h"

namespace facebook::velox::functions::aggregate::sparksql {

namespace {

exec::AggregateRegistrationResult registerMin(
const std::string& name,
bool withCompanionFunctions,
Expand Down Expand Up @@ -64,7 +66,11 @@ exec::AggregateRegistrationResult registerMax(
std::vector<TypePtr> argTypes,
const TypePtr& resultType,
const core::QueryConfig& config) -> std::unique_ptr<exec::Aggregate> {
auto factory = getMaxFunctionFactory(name, true, false, false);
auto factory = getMaxFunctionFactory(
name,
true /*nestedNullAllowed*/,
false /*mapTypeSupported*/,
false /*useMillisPrecision*/);
return factory(step, argTypes, resultType, config);
},
{false /*orderSensitive*/},
Expand Down

0 comments on commit de9d83f

Please sign in to comment.