This is an automated email from the ASF dual-hosted git repository. dbecker pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 3e4fdeece1735de85c17155dda626e8f28af0092 Author: jasonmfehr <[email protected]> AuthorDate: Mon Mar 25 17:03:33 2024 -0700 IMPALA-12824: Removes the prettyprint_duration Built-in Function The prettyprint_duration function was originally implemented in IMPALA-12824 to work with the workload management tables which stored durations in integer nanoseconds. These tables have changed to store decimal seconds. The prettyprint_duration function would have required a large investment of time to make it work with decimal values, and since the new format is more human readable anyways, this function has been removed. Change-Id: If2154c2ed9a7217ed4b7587adeae87df55ff03dc Reviewed-on: http://gerrit.cloudera.org:8080/21208 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- be/src/benchmarks/expr-benchmark.cc | 5 +- be/src/exprs/expr-test.cc | 31 ------ be/src/exprs/string-functions-ir.cc | 22 +--- be/src/exprs/string-functions.h | 7 -- common/function-registry/impala_functions.py | 4 - docs/topics/impala_functions.xml | 7 -- docs/topics/impala_string_functions.xml | 43 -------- .../queries/QueryTest/prettyprint-duration.test | 120 --------------------- tests/query_test/test_prettyprint_duration.py | 35 ------ 9 files changed, 2 insertions(+), 272 deletions(-) diff --git a/be/src/benchmarks/expr-benchmark.cc b/be/src/benchmarks/expr-benchmark.cc index dfc7ad27c..a006c8610 100644 --- a/be/src/benchmarks/expr-benchmark.cc +++ b/be/src/benchmarks/expr-benchmark.cc @@ -556,9 +556,8 @@ Benchmark* BenchmarkConditionalFunctions(bool codegen) { // find_in_set 321 323 325 0.765X 0.761X 0.76X // regexp_extract 42 42.8 43 0.1X 0.101X 0.101X // regexp_replace 2.94 2.96 3 0.00701X 0.00698X 0.00702X -// prettyprint_duration 18.3 18.6 18.7 0.0437X 0.0439X 0.0438X // prettyprint_bytes 9.54 9.72 9.75 0.0227X 0.0229X 0.0228X -// +// // StringFnCodegen: Function iters/ms 10%ile 50%ile 90%ile 10%ile 50%ile 90%ile // (relative) (relative) (relative) // --------------------------------------------------------------------------------------------------------- @@ -588,7 +587,6 @@ Benchmark* BenchmarkConditionalFunctions(bool codegen) { // find_in_set 320 323 325 0.694X 0.693X 0.691X // regexp_extract 42.2 43 43.2 0.0915X 0.0922X 0.0918X // regexp_replace 2.89 2.94 3 0.00626X 0.00631X 0.00637X -// prettyprint_duration 18.3 18.6 18.7 0.0398X 0.04X 0.0397X // prettyprint_bytes 9.55 9.72 9.74 0.0207X 0.0208X 0.0207X Benchmark* BenchmarkStringFunctions(bool codegen) { Benchmark* suite = new Benchmark(BenchmarkName("StringFn", codegen)); @@ -618,7 +616,6 @@ Benchmark* BenchmarkStringFunctions(bool codegen) { BENCHMARK("find_in_set", "find_in_set('ab', 'abc,ad,ab,ade,cde')"); BENCHMARK("regexp_extract", "regexp_extract('abxcy1234a', 'a.x.y.*a', 0)"); BENCHMARK("regexp_replace", "regexp_replace('axcaycazc', '', 'r')"); - BENCHMARK("prettyprint_duration", "prettyprint_duration(123456789)"); BENCHMARK("prettyprint_bytes", "prettyprint_bytes(987654321)"); return suite; } diff --git a/be/src/exprs/expr-test.cc b/be/src/exprs/expr-test.cc index f487b4ed0..d77d02f9d 100644 --- a/be/src/exprs/expr-test.cc +++ b/be/src/exprs/expr-test.cc @@ -4347,37 +4347,6 @@ TEST_P(ExprTest, StringFunctions) { "jaro-winkler boost threshold values can range between 0.0 and 1.0\n"); } - // Test prettyprint_duration - TestStringValue("prettyprint_duration(-1)", "-1.000ns"); - TestStringValue("prettyprint_duration(0)", "0.000ns"); - TestStringValue("prettyprint_duration(1234)", "1.234us"); - TestStringValue("prettyprint_duration(123456789012)", "2m3s"); - TestStringValue("prettyprint_duration(12345678901292)", "3h25m"); - TestIsNull("prettyprint_duration(NULL)", TYPE_STRING); - - // Test at the type boundaries for tinyint. - TestStringValue("prettyprint_duration(127)", "127.000ns"); - TestStringValue("prettyprint_duration(128)", "128.000ns"); - TestStringValue("prettyprint_duration(-128)", "-128.000ns"); - TestStringValue("prettyprint_duration(-129)", "-129.000ns"); - - // Test at the type boundaries for smallint. - TestStringValue("prettyprint_duration(32767)", "32.767us"); - TestStringValue("prettyprint_duration(32768)", "32.768us"); - TestStringValue("prettyprint_duration(-32768)", "-32768.000ns"); - TestStringValue("prettyprint_duration(-32769)", "-32769.000ns"); - - // Test at the type boundaries for int. - TestStringValue("prettyprint_duration(2147483647)", "2s147ms"); - TestStringValue("prettyprint_duration(2147483648)", "2s147ms"); - TestStringValue("prettyprint_duration(-2147483648)", "-2147483648.000ns"); - TestStringValue("prettyprint_duration(-2147483649)", "-2147483649.000ns"); - - // Test at the type boundaries for bigint. - TestStringValue("prettyprint_duration(9223372036854775807)", "2562047h47m"); - TestStringValue("prettyprint_duration(-9223372036854775808)", - "-9223372036854775808.000ns"); - // Test prettyprint_bytes TestStringValue("prettyprint_bytes(-1234)", "-1.21 KB"); TestStringValue("prettyprint_bytes(0)", "0"); diff --git a/be/src/exprs/string-functions-ir.cc b/be/src/exprs/string-functions-ir.cc index c78a4a5bc..f68e483db 100644 --- a/be/src/exprs/string-functions-ir.cc +++ b/be/src/exprs/string-functions-ir.cc @@ -1907,26 +1907,6 @@ static StringVal prettyPrint(FunctionContext* context, const T& int_val, return result; } -StringVal StringFunctions::PrettyPrintDuration(FunctionContext* context, - const BigIntVal& duration_us) { - return prettyPrint(context, duration_us, TUnit::TIME_NS); -} - -StringVal StringFunctions::PrettyPrintDuration(FunctionContext* context, - const IntVal& duration_us) { - return prettyPrint(context, duration_us, TUnit::TIME_NS); -} - -StringVal StringFunctions::PrettyPrintDuration(FunctionContext* context, - const SmallIntVal& duration_us) { - return prettyPrint(context, duration_us, TUnit::TIME_NS); -} - -StringVal StringFunctions::PrettyPrintDuration(FunctionContext* context, - const TinyIntVal& duration_us) { - return prettyPrint(context, duration_us, TUnit::TIME_NS); -} - StringVal StringFunctions::PrettyPrintMemory(FunctionContext* context, const BigIntVal& bytes) { return prettyPrint(context, bytes, TUnit::BYTES); @@ -1947,4 +1927,4 @@ StringVal StringFunctions::PrettyPrintMemory(FunctionContext* context, return prettyPrint(context, bytes, TUnit::BYTES); } -} \ No newline at end of file +} diff --git a/be/src/exprs/string-functions.h b/be/src/exprs/string-functions.h index 0d15490dd..2121caf28 100644 --- a/be/src/exprs/string-functions.h +++ b/be/src/exprs/string-functions.h @@ -236,13 +236,6 @@ class StringFunctions { const StringVal& s2, const DoubleVal& scaling_factor, const DoubleVal& boost_threshold); - /// Converts nanoseconds stored as an integer value into human readable time durations. - /// For example, 2147483647 nanoseconds is converted to "2s147ms". - static StringVal PrettyPrintDuration(FunctionContext*, const BigIntVal& duration_us); - static StringVal PrettyPrintDuration(FunctionContext*, const IntVal& duration_us); - static StringVal PrettyPrintDuration(FunctionContext*, const SmallIntVal& duration_us); - static StringVal PrettyPrintDuration(FunctionContext*, const TinyIntVal& duration_us); - /// Converts bytes stored as an integer value into human readable memory measurements. /// For example, 123456789012 bytes is converted to "114.98 GB". static StringVal PrettyPrintMemory(FunctionContext*, const BigIntVal& bytes); diff --git a/common/function-registry/impala_functions.py b/common/function-registry/impala_functions.py index d59398414..056eec1df 100644 --- a/common/function-registry/impala_functions.py +++ b/common/function-registry/impala_functions.py @@ -610,10 +610,6 @@ visible_functions = [ [['parse_url'], 'STRING', ['STRING', 'STRING', 'STRING'], 'impala::StringFunctions::ParseUrlKey', '_ZN6impala15StringFunctions15ParseUrlPrepareEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE', '_ZN6impala15StringFunctions13ParseUrlCloseEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE'], - [['prettyprint_duration'], 'STRING', ['BIGINT'], 'impala::StringFunctions::PrettyPrintDuration'], - [['prettyprint_duration'], 'STRING', ['INT'], 'impala::StringFunctions::PrettyPrintDuration'], - [['prettyprint_duration'], 'STRING', ['SMALLINT'], 'impala::StringFunctions::PrettyPrintDuration'], - [['prettyprint_duration'], 'STRING', ['TINYINT'], 'impala::StringFunctions::PrettyPrintDuration'], [['prettyprint_bytes'], 'STRING', ['BIGINT'], 'impala::StringFunctions::PrettyPrintMemory'], [['prettyprint_bytes'], 'STRING', ['INT'], 'impala::StringFunctions::PrettyPrintMemory'], [['prettyprint_bytes'], 'STRING', ['SMALLINT'], 'impala::StringFunctions::PrettyPrintMemory'], diff --git a/docs/topics/impala_functions.xml b/docs/topics/impala_functions.xml index 4aad813e3..ed9d18492 100644 --- a/docs/topics/impala_functions.xml +++ b/docs/topics/impala_functions.xml @@ -1036,13 +1036,6 @@ under the License. >PRECISION</xref> </entry> </row> - <row> - <entry> - <xref href= - "impala_string_functions.xml#string_functions/prettyprint_duration"> - PRETTYPRINT_DURATION</xref> - </entry> - </row> <row> <entry> <xref href= diff --git a/docs/topics/impala_string_functions.xml b/docs/topics/impala_string_functions.xml index 8774d1840..5772911ee 100644 --- a/docs/topics/impala_string_functions.xml +++ b/docs/topics/impala_string_functions.xml @@ -182,10 +182,6 @@ under the License. <xref href="#string_functions/parse_url">PARSE_URL</xref> </li> - <li> - <xref href="#string_functions/prettyprint_duration">PRETTYPRINT_DURATION</xref> - </li> - <li> <xref href="#string_functions/prettyprint_bytes">PRETTYPRINT_BYTES</xref> </li> @@ -1138,45 +1134,6 @@ select instr('foo bar bletch', 'b', 1, 2); </dlentry> - <dlentry id="prettyprint_duration"> - - <dt> - PRETTYPRINT_DURATION(TINYINT / SMALLINT / INT / BIGINT nanoseconds) - </dt> - - <dd> - <b>Purpose:</b> Formats numeric nanoseconds in a human readable manner. - <p> - <b>Return type:</b> <codeph>STRING</codeph> - </p> - - <p> - <b>Usage notes:</b> - </p> - - <p> - Negative durations are not fully supported. No conversion to milliseconds/seconds/minutes/hours - is performed. The input value is directly returned with the <codeph>ns</codeph> suffix added. - </p> - - <p> - <b>Examples:</b> - </p> - - <p> -<codeblock> -select prettyprint_duration(1), prettyprint_duration(12345678), prettyprint_duration(1234567890123), prettyprint_duration(98765432141451), prettyprint_duration(-436512); - -+-------------------------+--------------------------------+-------------------------------------+--------------------------------------+-------------------------------+ -| prettyprint_duration(1) | prettyprint_duration(12345678) | prettyprint_duration(1234567890123) | prettyprint_duration(98765432141451) | prettyprint_duration(-436512) | -+-------------------------+--------------------------------+-------------------------------------+--------------------------------------+-------------------------------+ -| 1.000ns | 12.345ms | 20m34s | 27h26m | -436512.000ns | -+-------------------------+--------------------------------+-------------------------------------+--------------------------------------+-------------------------------+ -</codeblock> - </p> - </dd> - </dlentry> - <dlentry id="prettyprint_bytes"> <dt> diff --git a/testdata/workloads/functional-query/queries/QueryTest/prettyprint-duration.test b/testdata/workloads/functional-query/queries/QueryTest/prettyprint-duration.test deleted file mode 100644 index 76cc30690..000000000 --- a/testdata/workloads/functional-query/queries/QueryTest/prettyprint-duration.test +++ /dev/null @@ -1,120 +0,0 @@ -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-1); ----- TYPES -string ----- RESULTS -'-1.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(0); ----- TYPES -string ----- RESULTS -'0.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(127); ----- TYPES -string ----- RESULTS -'127.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(128); ----- TYPES -string ----- RESULTS -'128.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-128); ----- TYPES -string ----- RESULTS -'-128.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-129); ----- TYPES -string ----- RESULTS -'-129.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(32767); ----- TYPES -string ----- RESULTS -'32.767us' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(32768); ----- TYPES -string ----- RESULTS -'32.768us' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-32768); ----- TYPES -string ----- RESULTS -'-32768.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-32769); ----- TYPES -string ----- RESULTS -'-32769.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(2147483647); ----- TYPES -string ----- RESULTS -'2s147ms' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(2147483648); ----- TYPES -string ----- RESULTS -'2s147ms' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-2147483648); ----- TYPES -string ----- RESULTS -'-2147483648.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-2147483649); ----- TYPES -string ----- RESULTS -'-2147483649.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(9223372036854775807); ----- TYPES -string ----- RESULTS -'2562047h47m' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(-9223372036854775808); ----- TYPES -string ----- RESULTS -'-9223372036854775808.000ns' -==== ----- QUERY -SELECT PRETTYPRINT_DURATION(NULL); ----- TYPES -string ----- RESULTS -'NULL' -==== diff --git a/tests/query_test/test_prettyprint_duration.py b/tests/query_test/test_prettyprint_duration.py deleted file mode 100644 index 39b2e2218..000000000 --- a/tests/query_test/test_prettyprint_duration.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from __future__ import absolute_import, division, print_function -from tests.common.impala_test_suite import ImpalaTestSuite -import pytest - - -class TestPrettyPrintDuration(ImpalaTestSuite): - """Tests the built-in function prettyprint_duration.""" - - @classmethod - def get_workload(self): - return 'functional-query' - - def test_prettyprint_duration(self, vector): - if (vector.get_value('table_format').file_format != 'text' - or vector.get_value('table_format').compression_codec != 'none'): - # No need to run this test on all file formats - pytest.skip() - self.run_test_case('QueryTest/prettyprint-duration', vector)
