Skip to content

Conversation

@hubgeter
Copy link
Contributor

@hubgeter hubgeter commented Sep 20, 2024

bp #40695 and #41075
#41075 : fix #40695 mac compile

Proposed changes

Added three functions: normal_cdf, to_iso8601, from_iso8601_date

  1. normal_cdf(mean, sd, v) → double : Compute the Normal cdf with given mean and standard deviation (sd): P(N < value; mean, sd). The mean and value must be real values and the standard deviation must be a real and positive value (all of type DOUBLE).

  2. to_iso8601(DATE/DATETIME) → string For DATE type, it will be converted to YYYY-MM-DD. For DATETIME type, it will be converted to
    YYYY-MM-DDThh:mm:ss.xxxxxx.

  3. from_iso8601_date(string) → DATE Convert iso8601 string to DATE type.
    The supported iso8601 string formats are as follows:
    a. Year : YYYY
    b. Calendar dates : YYYY-MM-DD , YYYYMMDD , YYYY-MM
    c. Week dates : YYYY-Www , YYYYWww , YYYY-Www-D , YYYYWwwD
    d. Ordinal dates : YYYY-DDD , YYYYDDD
    You can refer to this document
    to understand what these formats mean
    Please note that:
    a. Each date and time value has a fixed number of digits that must be
    padded with leading zeros.
    b. The range of YYYY is 0001-9999.
    outside these rules, the correctness of the results is not guaranteed.

For illegal values, the result is NULL.

…_iso8601_date (apache#40695)

Added three functions: `normal_cdf`, `to_iso8601`, `from_iso8601_date`

1. `normal_cdf(mean, sd, v) → double` :
Compute the Normal cdf with given mean and standard deviation (sd): P(N
< value; mean, sd). The mean and value must be real values and the
standard deviation must be a real and positive value (all of type
DOUBLE).

2. `to_iso8601(DATE/DATETIME) → string`
For `DATE` type, it will be converted to `YYYY-MM-DD`.
For `DATETIME` type, it will be converted to
`YYYY-MM-DDThh:mm:ss.xxxxxx`.

3. `from_iso8601_date(string) →  DATE`
Convert iso8601 string to `DATE` type.
The supported iso8601 string formats are as follows:
    a.  Year : YYYY
    b. Calendar dates : YYYY-MM-DD   , YYYYMMDD ,   YYYY-MM
    c. Week dates : YYYY-Www  , YYYYWww  , YYYY-Www-D , YYYYWwwD
    d. Ordinal dates : YYYY-DDD , YYYYDDD
You can refer to this [document](https://en.wikipedia.org/wiki/ISO_8601)
to understand what these formats mean
Please note that:
a. Each date and time value has a fixed number of digits that must be
padded with leading zeros.
     b. The range of YYYY is 0001-9999.
outside these rules, the correctness of the results is not guaranteed.

For illegal values, the result is NULL.
@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@hubgeter
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' has cognitive complexity of 81 (threshold 50) [readability-function-cognitive-complexity]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1443: +1, including nesting penalty of 0, nesting level increased to 1

        for (size_t i = 0; i < input_rows_count; ++i) {
        ^

be/src/vec/functions/function_timestamp.cpp:1454: +2, including nesting penalty of 1, nesting level increased to 2

            if (src_string.size() <= 10) {
            ^

be/src/vec/functions/function_timestamp.cpp:1460: +3, including nesting penalty of 2, nesting level increased to 3

                for (int idx = 0; idx < src_string.size();) {
                ^

be/src/vec/functions/function_timestamp.cpp:1462: +4, including nesting penalty of 3, nesting level increased to 4

                    if (current == '-') {
                    ^

be/src/vec/functions/function_timestamp.cpp:1466: +1, nesting level increased to 4

                    } else if (current == 'W') {
                           ^

be/src/vec/functions/function_timestamp.cpp:1470: +1, nesting level increased to 4

                    } else if (!isdigit(current)) {
                           ^

be/src/vec/functions/function_timestamp.cpp:1475: +4, including nesting penalty of 3, nesting level increased to 4

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                    ^

be/src/vec/functions/function_timestamp.cpp:1475: +1

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                                                   ^

be/src/vec/functions/function_timestamp.cpp:1480: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/functions/function_timestamp.cpp:1485: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value != -1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1497: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value == 1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1498: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month, &day) != 3)
                ^

be/src/vec/functions/function_timestamp.cpp:1504: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1505: +1

                      ts_value.template set_time_unit<MONTH>(month) &&
                                                                    ^

be/src/vec/functions/function_timestamp.cpp:1509: +1, nesting level increased to 2

            } else if (iso_string_format_value == 2) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1510: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1516: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1516: +1

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                                                                  ^

be/src/vec/functions/function_timestamp.cpp:1521: +1, nesting level increased to 2

            } else if (iso_string_format_value == 3) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1522: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year) != 1) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1527: +3, including nesting penalty of 2, nesting level increased to 3

                if (!ts_value.template set_time_unit<YEAR>(year)) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1533: +1, nesting level increased to 2

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1533: +1

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                                                    ^

be/src/vec/functions/function_timestamp.cpp:1534: +3, including nesting penalty of 2, nesting level increased to 3

                if (iso_string_format_value == 5) {
                ^

be/src/vec/functions/function_timestamp.cpp:1535: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week) != 2)
                    ^

be/src/vec/functions/function_timestamp.cpp:1540: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1541: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week,
                    ^

be/src/vec/functions/function_timestamp.cpp:1548: +3, including nesting penalty of 2, nesting level increased to 3

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1548: +1

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                                                           ^

be/src/vec/functions/function_timestamp.cpp:1564: +1, nesting level increased to 2

            } else if (iso_string_format_value == 4) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1565: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &day_of_year) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1571: +3, including nesting penalty of 2, nesting level increased to 3

                if (is_leap(year)) {
                ^

be/src/vec/functions/function_timestamp.cpp:1572: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1572: +1

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1575: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1576: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1576: +1

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1585: +1, nesting level increased to 2

            } else {
              ^

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' exceeds recommended size/complexity thresholds [readability-function-size]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1385: 206 lines including whitespace and comments (threshold 80)

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^

@hubgeter
Copy link
Contributor Author

run buildall

1 similar comment
@hubgeter
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' has cognitive complexity of 81 (threshold 50) [readability-function-cognitive-complexity]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1443: +1, including nesting penalty of 0, nesting level increased to 1

        for (size_t i = 0; i < input_rows_count; ++i) {
        ^

be/src/vec/functions/function_timestamp.cpp:1454: +2, including nesting penalty of 1, nesting level increased to 2

            if (src_string.size() <= 10) {
            ^

be/src/vec/functions/function_timestamp.cpp:1460: +3, including nesting penalty of 2, nesting level increased to 3

                for (int idx = 0; idx < src_string.size();) {
                ^

be/src/vec/functions/function_timestamp.cpp:1462: +4, including nesting penalty of 3, nesting level increased to 4

                    if (current == '-') {
                    ^

be/src/vec/functions/function_timestamp.cpp:1466: +1, nesting level increased to 4

                    } else if (current == 'W') {
                           ^

be/src/vec/functions/function_timestamp.cpp:1470: +1, nesting level increased to 4

                    } else if (!isdigit(current)) {
                           ^

be/src/vec/functions/function_timestamp.cpp:1475: +4, including nesting penalty of 3, nesting level increased to 4

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                    ^

be/src/vec/functions/function_timestamp.cpp:1475: +1

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                                                   ^

be/src/vec/functions/function_timestamp.cpp:1480: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/functions/function_timestamp.cpp:1485: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value != -1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1497: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value == 1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1498: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month, &day) != 3)
                ^

be/src/vec/functions/function_timestamp.cpp:1504: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1505: +1

                      ts_value.template set_time_unit<MONTH>(month) &&
                                                                    ^

be/src/vec/functions/function_timestamp.cpp:1509: +1, nesting level increased to 2

            } else if (iso_string_format_value == 2) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1510: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1516: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1516: +1

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                                                                  ^

be/src/vec/functions/function_timestamp.cpp:1521: +1, nesting level increased to 2

            } else if (iso_string_format_value == 3) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1522: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year) != 1) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1527: +3, including nesting penalty of 2, nesting level increased to 3

                if (!ts_value.template set_time_unit<YEAR>(year)) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1533: +1, nesting level increased to 2

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1533: +1

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                                                    ^

be/src/vec/functions/function_timestamp.cpp:1534: +3, including nesting penalty of 2, nesting level increased to 3

                if (iso_string_format_value == 5) {
                ^

be/src/vec/functions/function_timestamp.cpp:1535: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week) != 2)
                    ^

be/src/vec/functions/function_timestamp.cpp:1540: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1541: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week,
                    ^

be/src/vec/functions/function_timestamp.cpp:1548: +3, including nesting penalty of 2, nesting level increased to 3

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1548: +1

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                                                           ^

be/src/vec/functions/function_timestamp.cpp:1563: +1, nesting level increased to 2

            } else if (iso_string_format_value == 4) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1564: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &day_of_year) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1570: +3, including nesting penalty of 2, nesting level increased to 3

                if (is_leap(year)) {
                ^

be/src/vec/functions/function_timestamp.cpp:1571: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1571: +1

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1574: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1575: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1575: +1

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1584: +1, nesting level increased to 2

            } else {
              ^

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' exceeds recommended size/complexity thresholds [readability-function-size]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1385: 205 lines including whitespace and comments (threshold 80)

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.16% (9336/25819)
Line Coverage: 27.69% (76645/276803)
Region Coverage: 26.48% (39376/148683)
Branch Coverage: 23.28% (20049/86128)
Coverage Report: http://coverage.selectdb-in.cc/coverage/5df1aaa658c9111ec0617ab1ef86f614458bb50f_5df1aaa658c9111ec0617ab1ef86f614458bb50f/report/index.html

@hubgeter
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' has cognitive complexity of 90 (threshold 50) [readability-function-cognitive-complexity]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1443: +1, including nesting penalty of 0, nesting level increased to 1

        for (size_t i = 0; i < input_rows_count; ++i) {
        ^

be/src/vec/functions/function_timestamp.cpp:1454: +2, including nesting penalty of 1, nesting level increased to 2

            if (src_string.size() <= 10) {
            ^

be/src/vec/functions/function_timestamp.cpp:1460: +3, including nesting penalty of 2, nesting level increased to 3

                for (int idx = 0; idx < src_string.size();) {
                ^

be/src/vec/functions/function_timestamp.cpp:1462: +4, including nesting penalty of 3, nesting level increased to 4

                    if (current == '-') {
                    ^

be/src/vec/functions/function_timestamp.cpp:1466: +1, nesting level increased to 4

                    } else if (current == 'W') {
                           ^

be/src/vec/functions/function_timestamp.cpp:1470: +1, nesting level increased to 4

                    } else if (!isdigit(current)) {
                           ^

be/src/vec/functions/function_timestamp.cpp:1475: +4, including nesting penalty of 3, nesting level increased to 4

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                    ^

be/src/vec/functions/function_timestamp.cpp:1475: +1

                    for (; idx < src_string.size() && isdigit(src_string[idx]); ++idx) {
                                                   ^

be/src/vec/functions/function_timestamp.cpp:1480: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/functions/function_timestamp.cpp:1485: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value != -1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1497: +2, including nesting penalty of 1, nesting level increased to 2

            if (iso_string_format_value == 1) {
            ^

be/src/vec/functions/function_timestamp.cpp:1498: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month, &day) != 3)
                ^

be/src/vec/functions/function_timestamp.cpp:1504: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1505: +1

                      ts_value.template set_time_unit<MONTH>(month) &&
                                                                    ^

be/src/vec/functions/function_timestamp.cpp:1509: +1, nesting level increased to 2

            } else if (iso_string_format_value == 2) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1510: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &month) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1516: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1517: +1

                      ts_value.template set_time_unit<MONTH>(month) &&
                                                                    ^

be/src/vec/functions/function_timestamp.cpp:1522: +1, nesting level increased to 2

            } else if (iso_string_format_value == 3) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1523: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year) != 1) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1528: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1529: +1

                      ts_value.template set_time_unit<MONTH>(1) &&
                                                                ^

be/src/vec/functions/function_timestamp.cpp:1534: +1, nesting level increased to 2

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1534: +1

            } else if (iso_string_format_value == 5 || iso_string_format_value == 6) {
                                                    ^

be/src/vec/functions/function_timestamp.cpp:1535: +3, including nesting penalty of 2, nesting level increased to 3

                if (iso_string_format_value == 5) {
                ^

be/src/vec/functions/function_timestamp.cpp:1536: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week) != 2)
                    ^

be/src/vec/functions/function_timestamp.cpp:1541: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1542: +4, including nesting penalty of 3, nesting level increased to 4

                    if (sscanf(src_string.data(), iso_format_string.data(), &year, &week,
                    ^

be/src/vec/functions/function_timestamp.cpp:1549: +3, including nesting penalty of 2, nesting level increased to 3

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                ^

be/src/vec/functions/function_timestamp.cpp:1549: +1

                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) [[unlikely]] {
                                                           ^

be/src/vec/functions/function_timestamp.cpp:1555: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(
                ^

be/src/vec/functions/function_timestamp.cpp:1558: +1

                              first_day_of_week.month().operator unsigned int()) &&
                                                                                 ^

be/src/vec/functions/function_timestamp.cpp:1569: +1, nesting level increased to 2

            } else if (iso_string_format_value == 4) {
                   ^

be/src/vec/functions/function_timestamp.cpp:1570: +3, including nesting penalty of 2, nesting level increased to 3

                if (sscanf(src_string.data(), iso_format_string.data(), &year, &day_of_year) != 2)
                ^

be/src/vec/functions/function_timestamp.cpp:1576: +3, including nesting penalty of 2, nesting level increased to 3

                if (is_leap(year)) {
                ^

be/src/vec/functions/function_timestamp.cpp:1577: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1577: +1

                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1580: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/functions/function_timestamp.cpp:1581: +4, including nesting penalty of 3, nesting level increased to 4

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                    ^

be/src/vec/functions/function_timestamp.cpp:1581: +1

                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
                                        ^

be/src/vec/functions/function_timestamp.cpp:1585: +3, including nesting penalty of 2, nesting level increased to 3

                if (!(ts_value.template set_time_unit<YEAR>(year) &&
                ^

be/src/vec/functions/function_timestamp.cpp:1586: +1

                      ts_value.template set_time_unit<MONTH>(1) &&
                                                                ^

be/src/vec/functions/function_timestamp.cpp:1594: +1, nesting level increased to 2

            } else {
              ^

return make_nullable(std::make_shared<DataTypeDateV2>());
}

static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'execute' exceeds recommended size/complexity thresholds [readability-function-size]

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^
Additional context

be/src/vec/functions/function_timestamp.cpp:1385: 215 lines including whitespace and comments (threshold 80)

    static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                  ^

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.16% (9336/25819)
Line Coverage: 27.70% (76682/276811)
Region Coverage: 26.47% (39366/148703)
Branch Coverage: 23.27% (20049/86148)
Coverage Report: http://coverage.selectdb-in.cc/coverage/8cc3d81ea05faff19abacb3c189fdaba82ae0f79_8cc3d81ea05faff19abacb3c189fdaba82ae0f79/report/index.html

@hubgeter
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.15% (9337/25832)
Line Coverage: 27.68% (76656/276944)
Region Coverage: 26.47% (39385/148799)
Branch Coverage: 23.26% (20054/86204)
Coverage Report: http://coverage.selectdb-in.cc/coverage/db4256432964d6e64318dad1777a5f7aa8ea6319_db4256432964d6e64318dad1777a5f7aa8ea6319/report/index.html

@morningman morningman merged commit 2b427c3 into apache:branch-2.1 Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants