Skip to content

Commit

Permalink
SNOW-1820719 Refactor Session.sql Function (#175)
Browse files Browse the repository at this point in the history
* refactor session sql

* fix java api
  • Loading branch information
sfc-gh-bli committed Nov 22, 2024
1 parent 7688cfe commit 7e40133
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/snowflake/snowpark_java/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static SessionBuilder builder() {
* @since 0.8.0
*/
public DataFrame sql(String query) {
return new DataFrame(session.sql(query, JavaUtils.objectArrayToSeq(new Object[0])));
return new DataFrame(session.sql(query));
}

/**
Expand Down
17 changes: 15 additions & 2 deletions src/main/scala/com/snowflake/snowpark/Session.scala
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,24 @@ class Session private (private[snowpark] val conn: ServerConnection) extends Log
* You can use this method to execute an arbitrary SQL statement.
*
* @param query The SQL statement to execute.
* @param params for bind variables in SQL statement.
* @return A [[DataFrame]]
* @since 0.1.0
*/
def sql(query: String, params: Seq[Any] = Seq.empty): DataFrame = {
def sql(query: String): DataFrame = {
sql(query, Seq.empty)
}

/**
* Returns a new DataFrame representing the results of a SQL query.
*
* You can use this method to execute an arbitrary SQL statement.
*
* @param query The SQL statement to execute.
* @param params for bind variables in SQL statement.
* @return A [[DataFrame]]
* @since 1.15.0
*/
def sql(query: String, params: Seq[Any]): DataFrame = {
// PUT and GET command cannot be executed in async mode
DataFrame(this, plans.query(query, None, !Utils.isPutOrGetCommand(query), params))
}
Expand Down

0 comments on commit 7e40133

Please sign in to comment.