@@ -177,6 +177,58 @@ public void testTimestampBindingWithNTZTypeExceedingBindingThreshold() throws SQ
177177 statement .execute ("ALTER SESSION SET CLIENT_STAGE_ARRAY_BINDING_THRESHOLD = 1" );
178178 executePrepStmtForNumRows (connection , "stageinsert" , currT , 3 );
179179
180+ // Compare the results
181+ try (ResultSet rs1 = statement .executeQuery ("select * from stageinsert" );
182+ ResultSet rs2 = statement .executeQuery ("select * from regularinsert" )) {
183+ for (int i = 0 ; i < 3 ; i ++) {
184+ assertTrue (rs1 .next ());
185+ assertTrue (rs2 .next ());
186+
187+ assertEquals (rs1 .getInt (1 ), rs2 .getInt (1 ));
188+
189+ // Check tz type and ltz type columns have the same value.
190+ assertEquals (rs1 .getTimestamp (2 ), rs1 .getTimestamp (3 ));
191+
192+ assertEquals (rs2 .getTimestamp (2 ), rs2 .getTimestamp (2 ));
193+ assertEquals (rs1 .getTimestamp (3 ), rs1 .getTimestamp (3 ));
194+ assertEquals (rs2 .getTimestamp (4 ), rs2 .getTimestamp (4 ));
195+ }
196+ }
197+ } finally {
198+ statement .execute ("drop table if exists stageinsert" );
199+ statement .execute ("drop table if exists regularinsert" );
200+ TimeZone .setDefault (origTz );
201+ }
202+ }
203+ }
204+
205+ /**
206+ * Test that stage binding and regular binding insert and return the expected value for
207+ * timestamp_ntz, timestamp_ltz, and timestamp_tz when not exceeding binding threshold.
208+ *
209+ * @throws SQLException if there is an error during query execution.
210+ */
211+ @ Test
212+ public void testTimestampBindingWithNTZTypeNotExceedingBindingThreshold () throws SQLException {
213+ TimeZone .setDefault (tokyoTz );
214+ try (Connection connection = getConnection ();
215+ Statement statement = connection .createStatement ()) {
216+ try {
217+ statement .execute (
218+ "create or replace table stageinsert(ind int, ltz0 timestamp_ltz, tz0 timestamp_tz, ntz0 timestamp_ntz)" );
219+ statement .execute (
220+ "create or replace table regularinsert(ind int, ltz0 timestamp_ltz, tz0 timestamp_tz, ntz0 timestamp_ntz)" );
221+ statement .execute ("alter session set CLIENT_TIMESTAMP_TYPE_MAPPING=TIMESTAMP_NTZ" );
222+ statement .execute ("alter session set TIMEZONE='Asia/Tokyo'" );
223+ Timestamp currT = new Timestamp (System .currentTimeMillis ());
224+
225+ // insert using regular binging
226+ executePrepStmtForNumRows (connection , "regularinsert" , currT , 3 );
227+
228+ // insert using stage binding
229+ statement .execute ("ALTER SESSION SET CLIENT_STAGE_ARRAY_BINDING_THRESHOLD = 10" );
230+ executePrepStmtForNumRows (connection , "stageinsert" , currT , 3 );
231+
180232 // Compare the results
181233 try (ResultSet rs1 = statement .executeQuery ("select * from stageinsert" );
182234 ResultSet rs2 = statement .executeQuery ("select * from regularinsert" )) {
@@ -208,7 +260,7 @@ private void executePrepStmtForNumRows(
208260 try (PreparedStatement prepStatement =
209261 connection .prepareStatement ("insert into " + tableName + " values (?,?,?,?)" )) {
210262 for (int i = 0 ; i < numRows ; i ++) {
211- prepStatement .setInt (1 , 1 );
263+ prepStatement .setInt (1 , i );
212264 prepStatement .setTimestamp (2 , timestamp );
213265 prepStatement .setTimestamp (3 , timestamp );
214266 prepStatement .setTimestamp (4 , timestamp );
0 commit comments