Skip to content

Commit

Permalink
SNOW-1524152: Rename option for implicit server side query timeout (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz authored Jan 21, 2025
1 parent f2ec619 commit 9aaaa10
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/snowflake/client/core/SFBaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public abstract class SFBaseSession {

private boolean isJdbcArrowTreatDecimalAsInt = true;

private boolean supportImplicitAsyncQueryTimeout = false;
private boolean implicitServerSideQueryTimeout = false;

private boolean clearBatchOnlyAfterSuccessfulExecution = false;

Expand Down Expand Up @@ -1337,12 +1337,12 @@ public boolean getEnableReturnTimestampWithTimeZone() {
return enableReturnTimestampWithTimeZone;
}

boolean getSupportImplicitAsyncQueryTimeout() {
return supportImplicitAsyncQueryTimeout;
boolean getImplicitServerSideQueryTimeout() {
return implicitServerSideQueryTimeout;
}

void setSupportImplicitAsyncQueryTimeout(boolean supportImplicitAsyncQueryTimeout) {
this.supportImplicitAsyncQueryTimeout = supportImplicitAsyncQueryTimeout;
void setImplicitServerSideQueryTimeout(boolean value) {
this.implicitServerSideQueryTimeout = value;
}

void setClearBatchOnlyAfterSuccessfulExecution(boolean value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void addProperty(String propertyName, Object propertyValue) throws SFExce
if ("query_timeout".equalsIgnoreCase(propertyName)) {
// Client side implementation
queryTimeout = (Integer) propertyValue;
if (this.getSFBaseSession().getSupportImplicitAsyncQueryTimeout()) {
if (this.getSFBaseSession().getImplicitServerSideQueryTimeout()) {
// Set server parameter for supporting query timeout on async queries
statementParametersMap.put("STATEMENT_TIMEOUT_IN_SECONDS", (Integer) propertyValue);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ public void addSFSessionProperty(String propertyName, Object propertyValue) thro
}
break;

case SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT:
case IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT:
if (propertyValue != null) {
setSupportImplicitAsyncQueryTimeout(getBooleanValue(propertyValue));
setImplicitServerSideQueryTimeout(getBooleanValue(propertyValue));
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public enum SFSessionProperty {
JAVA_LOGGING_CONSOLE_STD_OUT_THRESHOLD(
"JAVA_LOGGING_CONSOLE_STD_OUT_THRESHOLD", false, String.class),

SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT(
"SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT", false, Boolean.class),
IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT("IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT", false, Boolean.class),

CLEAR_BATCH_ONLY_AFTER_SUCCESSFUL_EXECUTION(
"CLEAR_BATCH_ONLY_AFTER_SUCCESSFUL_EXECUTION", false, Boolean.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void testQueryIdIsSetOnFailedExecuteQuery() throws SQLException {
@Test
public void testSetQueryTimeoutForAsyncQueryUsingConnectionProperty() throws SQLException {
Properties p = new Properties();
p.put("SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT", true);
p.put("IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT", true);
try (Connection con = getConnection(p);
Statement statement = con.createStatement()) {
statement.setQueryTimeout(3);
Expand All @@ -334,15 +334,15 @@ public void testSetQueryTimeoutForAsyncQueryUsingConnectionProperty() throws SQL
}

/**
* Test for setting query timeout on regular queries with the SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT
* Test for setting query timeout on regular queries with the IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT
* property set to true. Applicable to versions after 3.21.0.
*
* @throws SQLException if there is an error when executing
*/
@Test
public void testSetQueryTimeoutWhenAsyncConnectionPropertySet() throws SQLException {
Properties p = new Properties();
p.put("SUPPORT_IMPLICIT_ASYNC_QUERY_TIMEOUT", true);
p.put("IMPLICIT_SERVER_SIDE_QUERY_TIMEOUT", true);
try (Connection con = getConnection(p);
Statement statement = con.createStatement()) {
statement.setQueryTimeout(3);
Expand Down

0 comments on commit 9aaaa10

Please sign in to comment.