Skip to content

Commit

Permalink
change type signature of cardinality from any to type var (facebookin…
Browse files Browse the repository at this point in the history
…cubator#10416)

Summary: 'any' is now treated as a concrete type by our underlying system, xstream. we need the signature to indicate it explicitly to be a type var.

Test Plan:
```
make unittest
```

it fails on 8 tests but are the same tests that fail on the main branch.

Reviewed By: Yuhta

Differential Revision: D59478826

Pulled By: kunigami

fbshipit-source-id: 17fcad023f6bf06cabd524fe7aab1a06726f161d
  • Loading branch information
kunigami authored and facebook-github-bot committed Jul 9, 2024
1 parent b1e1c77 commit bc5a813
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions velox/functions/prestosql/Cardinality.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ template <typename T>
struct CardinalityFunction {
VELOX_DEFINE_FUNCTION_TYPES(T);

void call(int64_t& out, const arg_type<Array<Any>>& input) {
void call(int64_t& out, const arg_type<Array<Generic<T1>>>& input) {
out = input.size();
}

void call(int64_t& out, const arg_type<Map<Any, Any>>& input) {
void call(
int64_t& out,
const arg_type<Map<Generic<T1>, Generic<T2>>>& input) {
out = input.size();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ void registerGeneralFunctions(const std::string& prefix) {

registerAllGreatestLeastFunctions(prefix);

registerFunction<CardinalityFunction, int64_t, Array<Any>>(
registerFunction<CardinalityFunction, int64_t, Array<Generic<T1>>>(
{prefix + "cardinality"});
registerFunction<CardinalityFunction, int64_t, Map<Any, Any>>(
registerFunction<CardinalityFunction, int64_t, Map<Generic<T1>, Generic<T2>>>(
{prefix + "cardinality"});

registerFailFunction({prefix + "fail"});
Expand Down
4 changes: 2 additions & 2 deletions velox/functions/prestosql/tests/HyperLogLogFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ TEST_F(HyperLogLogFunctionsTest, cardinalitySignatures) {
auto signatures = getSignatureStrings("cardinality");
ASSERT_EQ(3, signatures.size());

ASSERT_EQ(1, signatures.count("(map(any,any)) -> bigint"));
ASSERT_EQ(1, signatures.count("(array(any)) -> bigint"));
ASSERT_EQ(1, signatures.count("(map(__user_T1,__user_T2)) -> bigint"));
ASSERT_EQ(1, signatures.count("(array(__user_T1)) -> bigint"));
ASSERT_EQ(1, signatures.count("(hyperloglog) -> bigint"));
}

Expand Down

0 comments on commit bc5a813

Please sign in to comment.