Skip to content

Commit

Permalink
code review change
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jf committed Jul 25, 2024
1 parent 8bde225 commit 936da38
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
Expand Down Expand Up @@ -63,13 +62,12 @@ public ResultSetJsonVsArrowMultiTZIT(String queryResultFormat, String timeZone)
tz = timeZone;
}

private Connection init(String table, String column, String values) throws SQLException {
private void init(String table, String column, String values) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'");
statement.execute("create or replace table " + table + " " + column);
statement.execute("insert into " + table + " values " + values);
}
return connection;
}

@Test
Expand Down Expand Up @@ -110,8 +108,8 @@ public void testDate() throws Exception {
String column = "(a date)";

String values = "('" + StringUtils.join(cases, "'),('") + "'), (null)";
Connection con = init(table, column, values);
try (Statement statement = con.createStatement()) {
init(table, column, values);
try (Statement statement = connection.createStatement()) {
try (ResultSet rs = statement.executeQuery("select * from " + table)) {
int i = 0;
while (i < cases.length) {
Expand All @@ -135,8 +133,8 @@ public void testTimeWithScale(String[] times, int scale) throws SQLException {
String table = "test_arrow_time";
String column = "(a time(" + scale + "))";
String values = "('" + StringUtils.join(times, "'),('") + "'), (null)";
Connection con = init(table, column, values);
try (Statement statement = con.createStatement();
init(table, column, values);
try (Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from " + table)) {
for (int i = 0; i < times.length; i++) {
assertTrue(rs.next());
Expand Down Expand Up @@ -183,8 +181,8 @@ public void testTimestampNTZWithScale(int scale) throws SQLException {
String column = "(a timestamp_ntz(" + scale + "))";

String values = "('" + StringUtils.join(cases, "'),('") + "'), (null)";
Connection con = init(table, column, values);
try (Statement statement = con.createStatement()) {
init(table, column, values);
try (Statement statement = connection.createStatement()) {
try (ResultSet rs = statement.executeQuery("select * from " + table)) {
int i = 0;
while (i < cases.length) {
Expand Down Expand Up @@ -217,8 +215,8 @@ public void testTimestampNTZWithNanos() throws SQLException {
String column = "(a timestamp_ntz)";

String values = "('" + StringUtils.join(cases, "'),('") + "'), (null)";
Connection con = init(table, column, values);
try (Statement statement = con.createStatement()) {
init(table, column, values);
try (Statement statement = connection.createStatement()) {
try (ResultSet rs = statement.executeQuery("select * from " + table)) {
int i = 0;
while (i < cases.length) {
Expand Down

0 comments on commit 936da38

Please sign in to comment.