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

Fix executing empty sql statement in preactions and postactions #439

Open
meetchandan opened this issue Aug 15, 2019 · 5 comments
Open

Fix executing empty sql statement in preactions and postactions #439

meetchandan opened this issue Aug 15, 2019 · 5 comments

Comments

@meetchandan
Copy link

meetchandan commented Aug 15, 2019

Say for example:
you need to execute preactions/postactions

val preactions = "update table1 set col1=2; update table2 set col2 = 2; "
Looks nothing wrong, correct?

Only when you try to execute it, you will get weird error:

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0

This is because of Line 248 and Line 260 in Parameters.scala
def preActions: Array[String] = parameters("preactions").split(";")

def postActions: Array[String] = parameters("postactions").split(";")

the above functions are called in RedshiftWriter.scala LN: 132 and LN: 195
parameters("preactions").split(";")
-- this returns an array of 3 items, with the 3rd item being empty string (only spaces) - see trailing spaces in
val preactions = "update table1 set col1=2; update table2 set col2 = 2; "

and then it tries to execute sql query which is essentially just "spaces"

The fix is to just trim preactions and postactions so that the trailing spaces are not considered as query to be executed

@meetchandan
Copy link
Author

I am working on the fix and will soon raise a PR

@meetchandan
Copy link
Author

Link to PR:
#440

@meetchandan
Copy link
Author

meetchandan commented Aug 15, 2019

@JoshRosen @marmbrus @brkyvz Please take a look

@aleksandr-bogdanov
Copy link

Having the same issue, your fix would help a lot.

@meetchandan
Copy link
Author

can we merge this please @JoshRosen

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

No branches or pull requests

2 participants