Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array_frequency Presto function #3807

Closed

Conversation

vermapratyush
Copy link
Contributor

@vermapratyush vermapratyush commented Jan 25, 2023

Summary:

Test Plan

$ velox_expression_fuzzer_test --  --seed 100 --lazy_vector_generation_ratio 0.2 --duration_sec 600 --enable_variadic_signatures --velox_fuzzer_enable_complex_types --velox_fuzzer_enable_column_reuse --velox_fuzzer_enable_expression_reuse --retry_with_try --logtostderr=1 --minloglevel=0 --repro_persist_path=/tmp/fuzzer_repro --only array_frequency

I0126 12:37:10.402107 2149293 ExpressionFuzzer.cpp:949] ==============================> Done with iteration 22412
I0126 12:37:10.402221 2149293 ExpressionFuzzer.cpp:829] ==============================> Top 1 by number of rows processed
I0126 12:37:10.402263 2149293 ExpressionFuzzer.cpp:831] Format: functionName numTimesSelected proportionOfTimesSelected numProcessedRows
I0126 12:37:10.402277 2149293 ExpressionFuzzer.cpp:835] array_frequency 22413 100.00% 340170
I0126 12:37:10.402318 2149293 ExpressionFuzzer.cpp:841] ==============================> Bottom 1 by number of rows processed
I0126 12:37:10.402338 2149293 ExpressionFuzzer.cpp:843] Format: functionName numTimesSelected proportionOfTimesSelected numProcessedRows
I0126 12:37:10.402352 2149293 ExpressionFuzzer.cpp:848] array_frequency 22413 100.00% 340170
I0126 12:37:10.402372 2149293 ExpressionFuzzer.cpp:861] ==============================> All stats sorted by number of times the function was chosen
I0126 12:37:10.402385 2149293 ExpressionFuzzer.cpp:863] Format: functionName numTimesSelected proportionOfTimesSelected numProcessedRows
I0126 12:37:10.402405 2149293 ExpressionFuzzer.cpp:867] array_frequency 22413 100.00% 340170

Fuzzer on all functions

$ velox_expression_fuzzer_test --  --seed 100 --lazy_vector_generation_ratio 0.2 --duration_sec 600 --enable_variadic_signatures --velox_fuzzer_enable_complex_types --velox_fuzzer_enable_column_reuse --velox_fuzzer_enable_expression_reuse --retry_with_try --logtostderr=1 --minloglevel=0 --repro_persist_path=/tmp/fuzzer_repro

https://pastebin.com/1k4cGMhj

Fixes #3752

Differential Revision: D42712223

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 25, 2023
@netlify
Copy link

netlify bot commented Jan 25, 2023

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit a38b61f
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/63d418c7e797d500094989d5

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 25, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Differential Revision: D42712223

fbshipit-source-id: 6de391726abe4ad7731762874586c2037e94fef1
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

@vermapratyush
Copy link
Contributor Author

Failures unrelated to the diff.

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 25, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: 0a56eb6a0d9ad2fd8cbbac1bdb4aee4d113aba84
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 25, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: 4df80d6e6da84de5fdde99450b2110dda74e8f17
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 25, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: 2ee3ec58ba717120a83c9d88dbd90eb9e902cc71
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: cf29ac047b6988b5fd72d320887359064ab7573a
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

@netlify
Copy link

netlify bot commented Jan 26, 2023

Deploy Preview for bright-melba-465c6a failed.

Name Link
🔨 Latest commit a38b61f
🔍 Latest deploy log https://app.netlify.com/sites/bright-melba-465c6a/deploys/63d418c7f9770d000825450f

Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vermapratyush Thank you for adding one more Presto function. Would you update PR description with results of Fuzzer testing?

Implement array_frequency in velox with same signature as presto.

This statement is redundant. Consider removing.

velox/functions/prestosql/ArrayFunctions.h Outdated Show resolved Hide resolved

// optimization to skip counting frequency of null values
if (inputArray.mayHaveNulls()) {
for (const auto& item : inputArray.skipNulls()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we can't use this loop in all cases? CC: @laithsakka

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbasmanova the API is different as .skipNulls also unrolls the value. Hence in the subsequent branch is

frequencyCount[item.value()]++;
vs
frequencyCount[item]++;

velox/functions/prestosql/tests/ArrayFrequencyTest.cpp Outdated Show resolved Hide resolved
velox/functions/prestosql/tests/ArrayFrequencyTest.cpp Outdated Show resolved Hide resolved
velox/functions/prestosql/tests/ArrayFrequencyTest.cpp Outdated Show resolved Hide resolved
velox/functions/prestosql/tests/ArrayFrequencyTest.cpp Outdated Show resolved Hide resolved
vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: aa824bbe6ee32f59344b1c8c08a0c8fdd28e9c6a
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

@vermapratyush
Copy link
Contributor Author

@mbasmanova Running fuzzer without --only params failed with the following error.
Is this a known issue?

$ buck run //velox/expression/tests:velox_expression_fuzzer_test --  --seed 100 --lazy_vector_generation_ratio 0.2 --duration_sec 600 --enable_variadic_signatures --velox_fuzzer_enable_complex_types --velox_fuzzer_enable_column_reuse --velox_fuzzer_enable_expression_reuse --retry_with_try --logtostderr=1 --minloglevel=0 --repro_persist_path=/tmp/fuzzer_repr

terminate called after throwing an instance of 'facebook::velox::VeloxUserError'
  what():  Exception: VeloxUserError
Error Source: USER
Error Code: UNSUPPORTED
Reason: Unsupported map key type for element_at: INTERVAL DAY TO SECOND
Retriable: False
Function: applyMap
File: buck-out/dev/gen/aab7ed39/velox/functions/lib/velox_functions_lib#header-mode-symlink-tree-with-header-map,headers/velox/functions/lib/SubscriptUtil.h
Line: 144
Stack trace:
Stack trace has been disabled.Use --velox_exception_user_stacktrace=true to enable it.

*** Aborted at 1674764746 (Unix time, try 'date -d @1674764746') ***
*** Signal 6 (SIGABRT) (0x3227d0022efdd) received by PID 2289629 (pthread TID 0x7fc9898acf40) (linux TID 2289629) (maybe from PID 2289629, UID 205437) (code: -6), stack trace: ***
    @ 000000000001100e folly::symbolizer::(anonymous namespace)::innerSignalHandler(int, siginfo_t*, void*)
                       ./folly/experimental/symbolizer/SignalHandler.cpp:449
    @ 000000000000f731 folly::symbolizer::(anonymous namespace)::signalHandler(int, siginfo_t*, void*)
                       ./folly/experimental/symbolizer/SignalHandler.cpp:470
    @ 000000000004459f (unknown)
    @ 000000000009c9d3 __GI___pthread_kill
    @ 00000000000444ec __GI_raise
    @ 000000000002c432 __GI_abort
    @ 00000000000a3fd4 __gnu_cxx::__verbose_terminate_handler()
    @ 00000000000a1b39 __cxxabiv1::__terminate(void (*)())
    @ 00000000000a1ba4 std::terminate()
    @ 00000000000a1ec1 __cxa_rethrow
    @ 0000000000022874 facebook::velox::test::ExpressionVerifier::verify(std::shared_ptr<facebook::velox::core::ITypedExpr const> const&, std::shared_ptr<facebook::velox::RowVector> const&, std::shared_ptr<facebook::velox::BaseVector>&&, bool, std::vector<unsigned int, std::allocator<unsigned int> >)
                       ./velox/expression/tests/ExpressionVerifier.cpp:190
    @ 000000000009a0f1 facebook::velox::test::ExpressionFuzzer::go()
                       ./velox/expression/tests/ExpressionFuzzer.cpp:941
    @ 00000000000c8ce6 facebook::velox::test::expressionFuzzer(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<facebook::velox::exec::FunctionSignature const*, std::allocator<facebook::velox::exec::FunctionSignature const*> >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<facebook::velox::exec::FunctionSignature const*, std::allocator<facebook::velox::exec::FunctionSignature const*> > > > >, unsigned long)
                       ./velox/expression/tests/ExpressionFuzzer.cpp:957
    @ 00000000002e45cf FuzzerRunner::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::unordered_set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
                       ./velox/expression/tests/FuzzerRunner.h:140
                       -> ./velox/expression/tests/ExpressionFuzzerTest.cpp
    @ 00000000002e3da7 main
                       ./velox/expression/tests/ExpressionFuzzerTest.cpp:67
    @ 000000000002c656 __libc_start_call_main
    @ 000000000002c717 __libc_start_main_alias_2
    @ 00000000002c3580 _start
                       /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/csu/../sysdeps/x86_64/start.S:116

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: b1a37ebe291dc4b6dd9f951705fc00016a02d3c5
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

@mbasmanova
Copy link
Contributor

@vermapratyush This is a known issue that was fixed in #3801

Would you rebase and retry?

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: 36ffcf7c9a337a477ccc21421c8047b49afc9cd8
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta

Differential Revision: D42712223

fbshipit-source-id: 48fc72c9e09c83c0a246716a9fff56fbf4a990ac
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vermapratyush Thanks.

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta, mbasmanova

Differential Revision: D42712223

fbshipit-source-id: 48c73e9ab0574c01945af91f85913628bd5e01ad
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

vermapratyush added a commit to vermapratyush/velox that referenced this pull request Jan 27, 2023
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta, mbasmanova

Differential Revision: D42712223

fbshipit-source-id: 18e54975761581c50b798fef307c50556cdfdfaa
Summary:
Pull Request resolved: facebookincubator#3807

Implement `array_frequency` in velox with same signature [as presto](https://prestodb.io/docs/current/functions/array.html#array_frequency).

Fixes facebookincubator#3752

Reviewed By: Yuhta, mbasmanova

Differential Revision: D42712223

fbshipit-source-id: 8e4f37a040c5c3fff636dbdf473b9d3d38f5e24c
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D42712223

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 9971e7f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add array_frequency Presto function
3 participants