Skip to content

Commit 797aa77

Browse files
committed
fix test
1 parent 1e1f6ae commit 797aa77

File tree

5 files changed

+82
-23
lines changed

5 files changed

+82
-23
lines changed

src/main/java/net/snowflake/client/core/QueryExecDTO.java

+25
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ public class QueryExecDTO {
3030
// Boolean value that, if true, indicates query should be asynchronous
3131
private boolean asyncExec;
3232

33+
public QueryExecDTO(
34+
String sqlText,
35+
boolean describeOnly,
36+
Integer sequenceId,
37+
Map<String, ParameterBindingDTO> bindings,
38+
String bindStage,
39+
Map<String, Object> parameters,
40+
QueryContextDTO queryContext,
41+
long querySubmissionTime,
42+
boolean internal,
43+
boolean asyncExec) {
44+
this(
45+
sqlText,
46+
null,
47+
describeOnly,
48+
sequenceId,
49+
bindings,
50+
bindStage,
51+
parameters,
52+
queryContext,
53+
querySubmissionTime,
54+
internal,
55+
asyncExec);
56+
}
57+
3358
public QueryExecDTO(
3459
String sqlText,
3560
String dataframeAst,

src/main/java/net/snowflake/client/core/SFBaseStatement.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,16 @@ public abstract SFBaseResultSet execute(
9292
* @throws SFException exception raised from Snowflake components
9393
* @throws SQLException if SQL error occurs
9494
*/
95-
public abstract SFBaseResultSet execute(
95+
public SFBaseResultSet execute(
9696
String sql,
9797
String dataframeAst,
9898
Map<String, ParameterBindingDTO> parametersBinding,
9999
CallingMethod caller,
100100
ExecTimeTelemetryData execTimeData)
101-
throws SQLException, SFException;
101+
throws SQLException, SFException {
102+
// only used internally, not a public API
103+
throw new UnsupportedOperationException();
104+
}
102105

103106
/**
104107
* Execute sql asynchronously. Note that at a minimum, this does not have to be supported; if

src/main/java/net/snowflake/client/core/SFStatement.java

+51-1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,33 @@ public Void call() throws SQLException {
315315
executor.schedule(new TimeBombTask(this), this.queryTimeout, TimeUnit.SECONDS);
316316
}
317317

318+
/**
319+
* A helper method to build URL and submit the SQL to snowflake for exec
320+
*
321+
* @param sql sql statement
322+
* @param mediaType media type
323+
* @param bindValues map of binding values
324+
* @param describeOnly whether only show the result set metadata
325+
* @param internal run internal query not showing up in history
326+
* @param asyncExec is async execute
327+
* @param execTimeData ExecTimeTelemetryData
328+
* @return raw json response
329+
* @throws SFException if query is canceled
330+
* @throws SnowflakeSQLException if query is already running
331+
*/
332+
public Object executeHelper(
333+
String sql,
334+
String mediaType,
335+
Map<String, ParameterBindingDTO> bindValues,
336+
boolean describeOnly,
337+
boolean internal,
338+
boolean asyncExec,
339+
ExecTimeTelemetryData execTimeData)
340+
throws SnowflakeSQLException, SFException {
341+
return executeHelper(
342+
sql, null, mediaType, bindValues, describeOnly, internal, asyncExec, execTimeData);
343+
}
344+
318345
/**
319346
* A helper method to build URL and submit the SQL to snowflake for exec
320347
*
@@ -706,7 +733,7 @@ public SFBaseResultSet execute(
706733
CallingMethod caller,
707734
ExecTimeTelemetryData execTimeData)
708735
throws SQLException, SFException {
709-
return execute(sql, null, false, parametersBinding, caller, execTimeData);
736+
return execute(sql, false, parametersBinding, caller, execTimeData);
710737
}
711738

712739
@Override
@@ -762,6 +789,29 @@ private void cancelHelper(String sql, String mediaType, CancellationReason cance
762789
}
763790
}
764791

792+
/**
793+
* Execute sql
794+
*
795+
* @param sql sql statement.
796+
* @param asyncExec is async exec
797+
* @param parametersBinding parameters to bind
798+
* @param caller the JDBC interface method that called this method, if any
799+
* @param execTimeData ExecTimeTelemetryData
800+
* @return whether there is result set or not
801+
* @throws SQLException if failed to execute sql
802+
* @throws SFException exception raised from Snowflake components
803+
* @throws SQLException if SQL error occurs
804+
*/
805+
public SFBaseResultSet execute(
806+
String sql,
807+
boolean asyncExec,
808+
Map<String, ParameterBindingDTO> parametersBinding,
809+
CallingMethod caller,
810+
ExecTimeTelemetryData execTimeData)
811+
throws SQLException, SFException {
812+
return execute(sql, null, asyncExec, parametersBinding, caller, execTimeData);
813+
}
814+
765815
/**
766816
* Execute sql
767817
*

src/test/java/net/snowflake/client/jdbc/DataframeAstIT.java

-19
This file was deleted.

src/test/java/net/snowflake/client/jdbc/DataframeAstTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testSendAst() throws SQLException, IOException {
5252
anyBoolean(),
5353
any(),
5454
any()))
55-
.thenReturn("dummy");
55+
.thenReturn("{\"result\":\"dummy\"}");
5656
SnowflakeStatementV1 stmt =
5757
new SnowflakeStatementV1(
5858
mockedConn,

0 commit comments

Comments
 (0)