@@ -988,8 +988,6 @@ public void testStatsWithBinsOnTimeAndTermField_Avg() throws IOException {
988988
989989  @ Test 
990990  public  void  testBinTimestampBins20WithStats () throws  IOException  {
991-     // TODO: Remove this after addressing https://github.com/opensearch-project/sql/issues/4317 
992-     enabledOnlyWhenPushdownIsEnabled ();
993991
994992    // Test bins=20 with aggregation to verify OpenSearch auto_date_histogram behavior 
995993    // This corresponds to SPL test case 1: bins=20, range=307s 
@@ -1173,16 +1171,23 @@ public void testBinTimestampBins20WithoutAggregation() throws IOException {
11731171        executeQuery (
11741172            "source=opensearch-sql_test_index_time_bins_data | where @timestamp < '2025-07-28" 
11751173                + " 10:06:00' | bin @timestamp bins=20 | fields @timestamp, value | sort @timestamp" 
1176-                 + " | head 3 " );
1174+                 + " | head 10 " );
11771175
11781176    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
11791177
1180-     // All records from 10:00:00-10:00:29 should be binned to 2025-07-28 10:00:00  
1178+     // Verify 10 rows with 30-second interval bins  
11811179    verifyDataRows (
11821180        result ,
11831181        rows ("2025-07-28 10:00:00" , 8945 ),
11841182        rows ("2025-07-28 10:00:00" , 9012 ),
1185-         rows ("2025-07-28 10:00:00" , 6712 ));
1183+         rows ("2025-07-28 10:00:00" , 6712 ),
1184+         rows ("2025-07-28 10:00:30" , 8917 ),
1185+         rows ("2025-07-28 10:00:30" , 7162 ),
1186+         rows ("2025-07-28 10:01:00" , 8429 ),
1187+         rows ("2025-07-28 10:01:00" , 6985 ),
1188+         rows ("2025-07-28 10:01:30" , 6583 ),
1189+         rows ("2025-07-28 10:02:00" , 7823 ),
1190+         rows ("2025-07-28 10:02:00" , 9156 ));
11861191  }
11871192
11881193  @ Test 
@@ -1192,16 +1197,23 @@ public void testBinTimestampBins10WithoutAggregation() throws IOException {
11921197        executeQuery (
11931198            "source=opensearch-sql_test_index_time_bins_data | where @timestamp < '2025-07-28" 
11941199                + " 10:06:00' | bin @timestamp bins=10 | fields @timestamp, value | sort @timestamp" 
1195-                 + " | head 3 " );
1200+                 + " | head 10 " );
11961201
11971202    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
11981203
1199-     // All records from 10:00:00-10:00:59 should be binned to 2025-07-28 10:00:00  
1204+     // Verify 10 rows with 1-minute interval bins  
12001205    verifyDataRows (
12011206        result ,
12021207        rows ("2025-07-28 10:00:00" , 8945 ),
12031208        rows ("2025-07-28 10:00:00" , 9012 ),
1204-         rows ("2025-07-28 10:00:00" , 6712 ));
1209+         rows ("2025-07-28 10:00:00" , 6712 ),
1210+         rows ("2025-07-28 10:00:00" , 8917 ),
1211+         rows ("2025-07-28 10:00:00" , 7162 ),
1212+         rows ("2025-07-28 10:01:00" , 8429 ),
1213+         rows ("2025-07-28 10:01:00" , 6985 ),
1214+         rows ("2025-07-28 10:01:00" , 6583 ),
1215+         rows ("2025-07-28 10:02:00" , 7823 ),
1216+         rows ("2025-07-28 10:02:00" , 9156 ));
12051217  }
12061218
12071219  @ Test 
@@ -1211,16 +1223,23 @@ public void testBinTimestampBins5WithoutAggregation() throws IOException {
12111223        executeQuery (
12121224            "source=opensearch-sql_test_index_time_bins_data | where @timestamp < '2025-07-28" 
12131225                + " 10:06:00' | bin @timestamp bins=5 | fields @timestamp, value | sort @timestamp" 
1214-                 + " | head 3 " );
1226+                 + " | head 10 " );
12151227
12161228    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
12171229
1218-     // All records from 10:00:00-10:04:59 should be binned to 2025-07-28 10:00:00  
1230+     // Verify 10 rows with 5-minute interval bins (all in same bin)  
12191231    verifyDataRows (
12201232        result ,
12211233        rows ("2025-07-28 10:00:00" , 8945 ),
12221234        rows ("2025-07-28 10:00:00" , 9012 ),
1223-         rows ("2025-07-28 10:00:00" , 6712 ));
1235+         rows ("2025-07-28 10:00:00" , 6712 ),
1236+         rows ("2025-07-28 10:00:00" , 8917 ),
1237+         rows ("2025-07-28 10:00:00" , 7162 ),
1238+         rows ("2025-07-28 10:00:00" , 8429 ),
1239+         rows ("2025-07-28 10:00:00" , 6985 ),
1240+         rows ("2025-07-28 10:00:00" , 6583 ),
1241+         rows ("2025-07-28 10:00:00" , 7823 ),
1242+         rows ("2025-07-28 10:00:00" , 9156 ));
12241243  }
12251244
12261245  @ Test 
@@ -1229,16 +1248,23 @@ public void testBinTimestampBins10HoursWithoutAggregation() throws IOException {
12291248    JSONObject  result  =
12301249        executeQuery (
12311250            "source=opensearch-sql_test_index_time_bins_data | bin @timestamp bins=10 | fields" 
1232-                 + " @timestamp, value | sort @timestamp | head 3 " );
1251+                 + " @timestamp, value | sort @timestamp | head 10 " );
12331252
12341253    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
12351254
1236-     // Records from 10:00:00-10:59:59 should be binned to 2025-07-28 10:00:00  
1255+     // Verify 10 rows with 1-hour interval bins (all in same bin)  
12371256    verifyDataRows (
12381257        result ,
12391258        rows ("2025-07-28 10:00:00" , 8945 ),
12401259        rows ("2025-07-28 10:00:00" , 9012 ),
1241-         rows ("2025-07-28 10:00:00" , 6712 ));
1260+         rows ("2025-07-28 10:00:00" , 6712 ),
1261+         rows ("2025-07-28 10:00:00" , 8917 ),
1262+         rows ("2025-07-28 10:00:00" , 7162 ),
1263+         rows ("2025-07-28 10:00:00" , 8429 ),
1264+         rows ("2025-07-28 10:00:00" , 6985 ),
1265+         rows ("2025-07-28 10:00:00" , 6583 ),
1266+         rows ("2025-07-28 10:00:00" , 7823 ),
1267+         rows ("2025-07-28 10:00:00" , 9156 ));
12421268  }
12431269
12441270  @ Test 
@@ -1247,16 +1273,23 @@ public void testBinTimestampBins5HoursWithoutAggregation() throws IOException {
12471273    JSONObject  result  =
12481274        executeQuery (
12491275            "source=opensearch-sql_test_index_time_bins_data | bin @timestamp bins=5 | fields" 
1250-                 + " @timestamp, value | sort @timestamp | head 3 " );
1276+                 + " @timestamp, value | sort @timestamp | head 10 " );
12511277
12521278    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
12531279
1254-     // Records from 10:00:00-12:59:59 should be binned to 2025-07-28 10:00:00  
1280+     // Verify 10 rows with 3-hour interval bins (all in same bin)  
12551281    verifyDataRows (
12561282        result ,
12571283        rows ("2025-07-28 10:00:00" , 8945 ),
12581284        rows ("2025-07-28 10:00:00" , 9012 ),
1259-         rows ("2025-07-28 10:00:00" , 6712 ));
1285+         rows ("2025-07-28 10:00:00" , 6712 ),
1286+         rows ("2025-07-28 10:00:00" , 8917 ),
1287+         rows ("2025-07-28 10:00:00" , 7162 ),
1288+         rows ("2025-07-28 10:00:00" , 8429 ),
1289+         rows ("2025-07-28 10:00:00" , 6985 ),
1290+         rows ("2025-07-28 10:00:00" , 6583 ),
1291+         rows ("2025-07-28 10:00:00" , 7823 ),
1292+         rows ("2025-07-28 10:00:00" , 9156 ));
12601293  }
12611294
12621295  @ Test 
@@ -1265,15 +1298,22 @@ public void testBinTimestampBins3HoursWithoutAggregation() throws IOException {
12651298    JSONObject  result  =
12661299        executeQuery (
12671300            "source=opensearch-sql_test_index_time_bins_data | bin @timestamp bins=3 | fields" 
1268-                 + " @timestamp, value | sort @timestamp | head 3 " );
1301+                 + " @timestamp, value | sort @timestamp | head 10 " );
12691302
12701303    verifySchema (result , schema ("@timestamp" , null , "timestamp" ), schema ("value" , null , "int" ));
12711304
1272-     // Records from 10:00:00-12:59:59 should be binned to 2025-07-28 10:00:00  
1305+     // Verify 10 rows with 3-hour interval bins (all in same bin)  
12731306    verifyDataRows (
12741307        result ,
12751308        rows ("2025-07-28 10:00:00" , 8945 ),
12761309        rows ("2025-07-28 10:00:00" , 9012 ),
1277-         rows ("2025-07-28 10:00:00" , 6712 ));
1310+         rows ("2025-07-28 10:00:00" , 6712 ),
1311+         rows ("2025-07-28 10:00:00" , 8917 ),
1312+         rows ("2025-07-28 10:00:00" , 7162 ),
1313+         rows ("2025-07-28 10:00:00" , 8429 ),
1314+         rows ("2025-07-28 10:00:00" , 6985 ),
1315+         rows ("2025-07-28 10:00:00" , 6583 ),
1316+         rows ("2025-07-28 10:00:00" , 7823 ),
1317+         rows ("2025-07-28 10:00:00" , 9156 ));
12781318  }
12791319}
0 commit comments