> On July 13, 2016, 8:37 a.m., Peter Vary wrote:
> > Thanks for your patch!
> > This was a very annoying "feature" :)
> > 
> > As discussed offline, please look at DDLTask.java where the SHOW CREATE 
> > TABLE command is implemented. There is an escapeHiveCommand method, which 
> > escapes the result which is expected to be copy/pasted back to command line 
> > and executed without change.
> > 
> > Another thing your patch should consider, that the comment fields could 
> > contain escaped ' characters, like the one below:
> > 
> > ```
> > create table escape_comments_tbl1 (col1 string comment 'ab\';\');
> > ```
> > 
> > Thanks,
> > Peter

Thanks for pointing out the logic in DDLTask Peter. I hadn't thought about 
that. My solution was to basically remove the escaping of the `;` done in 
DDLTask. It no longer necessary since the create table queries can now handle 
`;` as long as they are inside quotation marks (I checked and all uses of the 
escapeHiveCommand return output that is enclosed in quotation marks). So the 
create table queries should work as expected. The old behavior is still 
preserved e.g. `'ab\;cd'` still works (there were existing test for this). It 
seems Hive internally strips the escape characters for characters that don't 
need to be escaped (ref: `BaseSemanticAnalyzer.unescapeSQLString(String)`.


- Sahil


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/49655/#review142036
-----------------------------------------------------------


On July 19, 2016, 7:45 p.m., Sahil Takiar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/49655/
> -----------------------------------------------------------
> 
> (Updated July 19, 2016, 7:45 p.m.)
> 
> 
> Review request for hive, Sergio Pena and Yongzhi Chen.
> 
> 
> Bugs: HIVE-12646
>     https://issues.apache.org/jira/browse/HIVE-12646
> 
> 
> Repository: hive-git
> 
> 
> Description
> -------
> 
> HIVE-12646: beeline and HIVE CLI do not parse ; in quote properly
> 
> Approach:
> 
>   * Modified the `Commands.execute(...)` command to iterate throught the 
> given input line character by character
>   * It looks for single and double quotes in order to track when the iterator 
> is inside a quotation block
>   * If the iterator is inside a quotation block and it finds a semicolon, it 
> ignores it, otherwise it treats it as it normally would
>   * Moved the logic for parsing the line into a helper method called 
> `getCmList(...)` which is responsible for returning a `List` of commands that 
> need to be run
> 
> 
> Diffs
> -----
> 
>   beeline/src/java/org/apache/hive/beeline/Commands.java 387861b 
>   
> itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
>  ecfeddb 
>   ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java 2b8d6a7 
> 
> Diff: https://reviews.apache.org/r/49655/diff/
> 
> 
> Testing
> -------
> 
> Add a unit tests which checks that Beeline can successfully run queries that 
> contain semi-colons inside quotation blocks. Confirmed existing unit tests 
> pass.
> 
> 
> Thanks,
> 
> Sahil Takiar
> 
>

Reply via email to