Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1022196 Support binding parameters for snowpark java api #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-evandenberg
Copy link
Contributor

SNOW-1022196 Support binding parameters for snowpark java api

* @param query The SQL statement to execute.
* @param params The binding parameters for SQL statement (optional)
* @return A {@code DataFrame} object
* @since 0.8.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since 0.8.0
* @since 1.15.0

@@ -857,20 +871,24 @@ private[snowpark] class ServerConnection(

logDebug(s"""execute plan in async mode:
|----------SNOW-----------
|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why added a new line?

val multipleStatements = queries.mkString("; ")
// Note binding parameters only supported for single query
val bindingParameters =
if (plan.queries.length == 1) plan.queries.last.params else Seq()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't support multiple statements, let's throw a user exception here.
you can find example from there https://github.com/snowflakedb/snowpark-java-scala/blob/main/src/main/scala/com/snowflake/snowpark/internal/ErrorMessage.scala

I checked the code, the only one usage is caching dataframe. So user can't cache dataframe if invoke binding.
I think we can improve it later. Now we cache dataframe by Create Table + Insert Into table, these two queries can be combined into one. Anyway, let's don't do it now, just throw one exception.

val df5 =
session.sql("select * from values (?,?),(?,?),(?,?) as T(a, b)", List(1, 2, 2, 1, 4, 3))
val df6 = df4.union(df5).filter(col("a") < 3)
assert(df6.collect() sameElements Array[Row](Row(1, 1), Row(2, 1), Row(1, 2)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should have two (2, 1) right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants