mirror of
https://github.com/apache/impala.git
synced 2025-12-30 03:01:44 -05:00
Shell: Fix parsing of strings containing an escaped backslash
Upgrading sqlparse ended up trading one bug for another. The new bug is not fixed upstream, I sent a patch. The problem is '\\' is not considered a terminated string and we use this in the phrase "fields escaped by '\\'" when creating tables. Change-Id: Id57081f5a96e997afd3aa9b26dca23f627488fc3 Reviewed-on: http://gerrit.cloudera.org:8080/117 Reviewed-by: Casey Ching <casey@cloudera.com> Tested-by: Internal Jenkins
This commit is contained in:
@@ -191,8 +191,7 @@ class Lexer(object):
|
||||
(r'[-]?[0-9]*(\.[0-9]+)?[eE][-]?[0-9]+', tokens.Number.Float),
|
||||
(r'[-]?[0-9]*\.[0-9]+', tokens.Number.Float),
|
||||
(r'[-]?[0-9]+', tokens.Number.Integer),
|
||||
# TODO: Backslash escapes?
|
||||
(r"'(''|\\'|[^'])*'", tokens.String.Single),
|
||||
(r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single),
|
||||
# not a real string literal in ANSI SQL:
|
||||
(r'(""|".*?[^\\]")', tokens.String.Symbol),
|
||||
(r'(\[.*[^\]]\])', tokens.Name),
|
||||
|
||||
@@ -22,6 +22,10 @@ class SQLSplitTest(TestCaseBase):
|
||||
self.ndiffAssertEqual(unicode(stmts[0]), self._sql1)
|
||||
self.ndiffAssertEqual(unicode(stmts[1]), sql2)
|
||||
|
||||
def test_split_backslash(self):
|
||||
stmts = sqlparse.parse(r"select '\\'; select '\''; select '\\\'';")
|
||||
self.assertEqual(len(stmts), 3)
|
||||
|
||||
def test_create_function(self):
|
||||
sql = load_file('function.sql')
|
||||
stmts = sqlparse.parse(sql)
|
||||
|
||||
Reference in New Issue
Block a user