Skip to content

Commit

Permalink
SNOW-538588 refactor to support async in stored proc (#1324)
Browse files Browse the repository at this point in the history
* SNOW-538588 refactor to support async in stored proc

* remove unwanted change

---------

Co-authored-by: Zihan Li <zihan.li@snowflake.com>
  • Loading branch information
sfc-gh-mrui and sfc-gh-zli authored Aug 14, 2023
1 parent dd30019 commit e3fb3b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/main/java/net/snowflake/client/core/SFBaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.google.common.base.Strings;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -793,6 +794,13 @@ public Object getSessionPropertyByKey(String propertyName) {
*/
public abstract boolean isSafeToClose();

/**
* @param queryID query ID of the query whose status is being investigated
* @return enum of type QueryStatus indicating the query's status
* @throws SQLException
*/
public abstract QueryStatus getQueryStatus(String queryID) throws SQLException;

/**
* Validates the connection properties used by this session, and returns a list of missing
* properties.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public void addQueryToActiveQueryList(String queryID) {
* @return enum of type QueryStatus indicating the query's status
* @throws SQLException
*/
@Override
public QueryStatus getQueryStatus(String queryID) throws SQLException {
// create the URL to check the query monitoring endpoint
String statusUrl = "";
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/snowflake/client/jdbc/SFAsyncResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.regex.Pattern;
import net.snowflake.client.core.QueryStatus;
import net.snowflake.client.core.SFBaseResultSet;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFSession;
import net.snowflake.common.core.SqlState;

Expand All @@ -23,7 +24,7 @@ class SFAsyncResultSet extends SnowflakeBaseResultSet implements SnowflakeResult
private ResultSet resultSetForNext = new SnowflakeResultSetV1.EmptyResultSet();
private boolean resultSetForNextInitialized = false;
private String queryID;
private SFSession session;
private SFBaseSession session;
private Statement extraStatement;
private QueryStatus lastQueriedStatus = NO_DATA;

Expand All @@ -42,7 +43,7 @@ class SFAsyncResultSet extends SnowflakeBaseResultSet implements SnowflakeResult
super(statement);
this.sfBaseResultSet = sfBaseResultSet;
this.queryID = sfBaseResultSet.getQueryId();
this.session = (SFSession) sfBaseResultSet.getSession();
this.session = sfBaseResultSet.getSession();
this.extraStatement = statement;
this.resultSetMetaData = new SnowflakeResultSetMetaDataV1(sfBaseResultSet.getMetaData());
this.resultSetMetaData.setQueryIdForAsyncResults(this.queryID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ public List<DriverPropertyInfo> checkProperties() {
@Override
public void close() {}

@Override
public QueryStatus getQueryStatus(String queryID) {
return null;
}

@Override
public Telemetry getTelemetryClient() {
return new Telemetry() {
Expand Down

0 comments on commit e3fb3b9

Please sign in to comment.