-
Notifications
You must be signed in to change notification settings - Fork 25
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: Update Copy parser to handle ',' separated option list #49
Conversation
single char regex to wider set of characters.
…o expand single char regex to wider set of characters.
@@ -242,6 +241,8 @@ private void parseCopyStatement() throws Exception { | |||
parse(sql, this.options); | |||
} catch (Exception e) { | |||
throw new SQLException("Invalid COPY statement syntax: " + e.toString()); | |||
} catch (TokenMgrError e) { |
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.
nit: you can combine the two catch clauses into one like this:
} catch (Exception | TokenMgrError e) {
throw new SQLException("Invalid COPY statement syntax: " + e.toString());
}
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.
Done.
assertThat(options.getDelimiter(), is(equalTo(value))); | ||
assertThat(options.getQuote(), is(equalTo(value1))); | ||
assertThat(options.getEscape(), is(equalTo(value2))); | ||
} |
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.
Can we add the following assertion (here and also for the other tests):
} | |
assertEquals(StatementParser.parseCommand(StatementParser.removeCommentsAndTrim(sql)), "COPY"); | |
} |
This assertion currently fails for ESCAPE '\'
, as our parser (correctly?) sees '' as an unclosed string literal.
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.
Yes, removeCommentsAndTrim() does not allow a single '\' in the statement. Copy expects the delimiter, escape, and quote options to be single characters.
Le'ts drop ', ", and \ for now. The logic in removeCommentsAndTrim() would break if we allowed those. We could add them back in at a later point after we rework removeCommentsAndTrim().
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.
yeah, that sounds reasonable.
Update Copy parser to handle ',' separated option list. Also expand single char regex to wider set of characters [! - ~].