Skip to content

Commit

Permalink
Updated tests, removed git ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jf committed Nov 15, 2024
1 parent 8383318 commit 3ddc536
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/test/java/net/snowflake/client/jdbc/BindingDataLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,12 @@ public void testTimestampBindingWithNTZType() throws SQLException {
}

/**
* Test that stage binding and regular binding insert and return the same value for timestamp_ntz
* when exceeding binding threshold.
* Test that stage binding and regular binding insert and return the expected value for
* timestamp_ntz, timestamp_ltz, and timestamp_tz when exceeding binding threshold.
*
* @throws SQLException
* @throws SQLException if there is an error during query execution.
*/
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
public void testTimestampBindingWithNTZTypeExceedingBindingThreshold() throws SQLException {
TimeZone.setDefault(tokyoTz);
try (Connection connection = getConnection();
Expand All @@ -140,15 +139,11 @@ public void testTimestampBindingWithNTZTypeExceedingBindingThreshold() throws SQ
Timestamp currT = new Timestamp(System.currentTimeMillis());

// insert using regular binging
executePsStatementForTimestampTest(connection, "regularinsert", currT);
executePsStatementForTimestampTest(connection, "regularinsert", currT);
executePsStatementForTimestampTest(connection, "regularinsert", currT);
executePrepStmtForNumRows(connection, "regularinsert", currT, 3);

// insert using stage binding
statement.execute("ALTER SESSION SET CLIENT_STAGE_ARRAY_BINDING_THRESHOLD = 1");
executePsStatementForTimestampTest(connection, "stageinsert", currT);
executePsStatementForTimestampTest(connection, "stageinsert", currT);
executePsStatementForTimestampTest(connection, "stageinsert", currT);
executePrepStmtForNumRows(connection, "stageinsert", currT, 3);

// Compare the results
try (ResultSet rs1 = statement.executeQuery("select * from stageinsert");
Expand All @@ -175,6 +170,22 @@ public void testTimestampBindingWithNTZTypeExceedingBindingThreshold() throws SQ
}
}

private void executePrepStmtForNumRows(
Connection connection, String tableName, Timestamp timestamp, int numRows)
throws SQLException {
try (PreparedStatement prepStatement =
connection.prepareStatement("insert into " + tableName + " values (?,?,?,?)")) {
for (int i = 0; i < numRows; i++) {
prepStatement.setInt(1, 1);
prepStatement.setTimestamp(2, timestamp);
prepStatement.setTimestamp(3, timestamp);
prepStatement.setTimestamp(4, timestamp);
prepStatement.addBatch();
}
prepStatement.executeBatch();
}
}

/**
* Test that stage binding and regular binding insert and return the same value for timestamp_ltz
*
Expand Down

0 comments on commit 3ddc536

Please sign in to comment.