Skip to content

Commit 9de9544

Browse files
committed
Fix flaky ExtractTest and update CI macOS runner
- Fix ExtractTest.testExtractDatePartWithTimeType() flaky WEEK assertion by using the same DateTimeFormatter("w", Locale.ENGLISH) calculation as the EXTRACT function instead of ALIGNED_WEEK_OF_YEAR - Update CI macOS runner from deprecated macos-13 to macos-14 Signed-off-by: Eric Wei <mengwei.eric@gmail.com>
1 parent 9e0de60 commit 9de9544

4 files changed

Lines changed: 28 additions & 30 deletions

File tree

.github/workflows/integ-tests-with-security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
strategy:
6161
fail-fast: false
6262
matrix:
63-
os: [ windows-latest, macos-13 ]
63+
os: [ windows-latest, macos-14 ]
6464
java: [ 11, 17, 21 ]
6565

6666
runs-on: ${{ matrix.os }}

.github/workflows/sql-test-and-build-workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ jobs:
105105
matrix:
106106
entry:
107107
- { os: windows-latest, java: 11, os_build_args: -x doctest -PbuildPlatform=windows }
108-
- { os: macos-13, java: 11}
108+
- { os: macos-14, java: 11}
109109
- { os: windows-latest, java: 17, os_build_args: -x doctest -PbuildPlatform=windows }
110-
- { os: macos-13, java: 17 }
110+
- { os: macos-14, java: 17 }
111111
- { os: windows-latest, java: 21, os_build_args: -x doctest -PbuildPlatform=windows }
112-
- { os: macos-13, java: 21 }
112+
- { os: macos-14, java: 21 }
113113
runs-on: ${{ matrix.entry.os }}
114114

115115
steps:

core/src/test/java/org/opensearch/sql/expression/datetime/ExtractTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
package org.opensearch.sql.expression.datetime;
77

8-
import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
98
import static org.junit.jupiter.api.Assertions.assertEquals;
109
import static org.opensearch.sql.data.type.ExprCoreType.LONG;
1110

1211
import java.time.LocalDate;
12+
import java.time.format.DateTimeFormatter;
13+
import java.util.Locale;
1314
import java.util.stream.Stream;
1415
import org.junit.jupiter.api.Test;
1516
import org.junit.jupiter.params.ParameterizedTest;
@@ -96,15 +97,12 @@ public void testExtractDatePartWithTimeType() {
9697

9798
datePartWithTimeArgQuery("DAY", timeInput, now.getDayOfMonth());
9899

99-
// To avoid flaky test, skip the testing in December and January because the WEEK is ISO 8601
100-
// week-of-week-based-year which is considered to start on a Monday and week 1 is the first week
101-
// with >3 days. it is possible for early-January dates to be part of the 52nd or 53rd week of
102-
// the previous year, and for late-December dates to be part of the first week of the next year.
103-
// For example, 2005-01-02 is part of the 53rd week of year 2004, while 2012-12-31 is part of
104-
// the first week of 2013
105-
if (now.getMonthValue() != 1 && now.getMonthValue() != 12) {
106-
datePartWithTimeArgQuery("WEEK", datetimeInput, now.get(ALIGNED_WEEK_OF_YEAR));
107-
}
100+
// Use the same week-of-year calculation as the EXTRACT function (DateTimeFormatter "w" with
101+
// Locale.ENGLISH) to avoid flaky mismatches. ALIGNED_WEEK_OF_YEAR uses simple arithmetic
102+
// (dayOfYear-1)/7+1 which diverges from the locale-aware week numbering on many dates.
103+
long expectedWeek =
104+
Long.parseLong(DateTimeFormatter.ofPattern("w", Locale.ENGLISH).format(now.atStartOfDay()));
105+
datePartWithTimeArgQuery("WEEK", datetimeInput, expectedWeek);
108106

109107
datePartWithTimeArgQuery("MONTH", timeInput, now.getMonthValue());
110108

docs/user/ppl/cmd/patterns.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ PPL query::
4949

5050
os> source=apache | patterns message | fields message, patterns_field ;
5151
fetched rows / total rows = 4/4
52-
+-----------------------------------------------------------------------------------------------------------------------------+---------------------------------+
53-
| message | patterns_field |
54-
|-----------------------------------------------------------------------------------------------------------------------------+---------------------------------|
55-
| 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | ... - [//::: -] " /-/ /." |
56-
| 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | ... - [//::: -] " //// /." |
57-
| 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | ... - - [//::: -] " //--- /." |
58-
| 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | ... - - [//::: -] " / /." |
59-
+-----------------------------------------------------------------------------------------------------------------------------+---------------------------------+
52+
+-----------------------------------------------------------------------------------------------------------------------------+-------------------------------+
53+
| message | patterns_field |
54+
|-----------------------------------------------------------------------------------------------------------------------------+-------------------------------|
55+
| 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | ... - [//::: -] " /-/ /." |
56+
| 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | ... - [//::: -] " //// /." |
57+
| 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | ... - - [//::: -] " //--- /." |
58+
| 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | ... - - [//::: -] " / /." |
59+
+-----------------------------------------------------------------------------------------------------------------------------+-------------------------------+
6060

6161
Example 3: Extract log patterns with custom regex pattern
6262
=========================================================
@@ -67,14 +67,14 @@ PPL query::
6767

6868
os> source=apache | patterns new_field='no_numbers' pattern='[0-9]' message | fields message, no_numbers ;
6969
fetched rows / total rows = 4/4
70-
+-----------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+
71-
| message | no_numbers |
72-
|-----------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------|
73-
| 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | ... - upton [/Sep/::: -] "HEAD /e-business/mindshare HTTP/." |
74-
| 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | ... - pouros [/Sep/::: -] "GET /architectures/convergence/niches/mindshare HTTP/." |
75-
| 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | ... - - [/Sep/::: -] "PATCH /strategize/out-of-the-box HTTP/." |
76-
| 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | ... - - [/Sep/::: -] "POST /users HTTP/." |
77-
+-----------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+
70+
+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
71+
| message | no_numbers |
72+
|-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------|
73+
| 177.95.8.74 - upton5450 [28/Sep/2022:10:15:57 -0700] "HEAD /e-business/mindshare HTTP/1.0" 404 19927 | ... - upton [/Sep/::: -] "HEAD /e-business/mindshare HTTP/." |
74+
| 127.45.152.6 - pouros8756 [28/Sep/2022:10:15:57 -0700] "GET /architectures/convergence/niches/mindshare HTTP/1.0" 100 28722 | ... - pouros [/Sep/::: -] "GET /architectures/convergence/niches/mindshare HTTP/." |
75+
| 118.223.210.105 - - [28/Sep/2022:10:15:57 -0700] "PATCH /strategize/out-of-the-box HTTP/1.0" 401 27439 | ... - - [/Sep/::: -] "PATCH /strategize/out-of-the-box HTTP/." |
76+
| 210.204.15.104 - - [28/Sep/2022:10:15:57 -0700] "POST /users HTTP/1.1" 301 9481 | ... - - [/Sep/::: -] "POST /users HTTP/." |
77+
+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
7878

7979
Limitation
8080
==========

0 commit comments

Comments
 (0)