-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: main
Are you sure you want to change the base?
SNOW-1022196 Support binding parameters for snowpark java api #171
Conversation
* @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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @since 0.8.0 | |
* @since 1.15.0 |
@@ -857,20 +871,24 @@ private[snowpark] class ServerConnection( | |||
|
|||
logDebug(s"""execute plan in async mode: | |||
|----------SNOW----------- | |||
| |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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?
SNOW-1022196 Support binding parameters for snowpark java api