Alex Behm has posted comments on this change. ( http://gerrit.cloudera.org:8080/8818 )
Change subject: IMPALA-3942: Fix wrongly escaped string literal in front-end ...................................................................... Patch Set 7: (8 comments) http://gerrit.cloudera.org:8080/#/c/8818/6/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java File fe/src/main/java/org/apache/impala/analysis/StringLiteral.java: http://gerrit.cloudera.org:8080/#/c/8818/6/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java@44 PS6, Line 44: this(value, ScalarType.STRING, true); > Done. By the way, would you tell me the reason why you don't want to keep t That's a fair question, thanks for asking! * In most cases there will be no redundant computation. The common case is that this literal is passed to the BE via toThrift() so getNormalizedValue() is only called once. * I'm less concerned about redundant computations and more concerned about doubling the memory consumption. This point will probably only matter in extreme cases. * Easier to reason about and maintain fewer class members. The normalized string is "redundant" information because it can be derived from 'value_'. http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java File fe/src/main/java/org/apache/impala/analysis/StringLiteral.java: http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java@87 PS7, Line 87: return BaseSemanticAnalyzer.unescapeSQLString("'" + getNormalizedValue() whitespace http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java@91 PS7, Line 91: // Assumes a string literal from single quotes and escapes it because: What does this function do and return? Please consider these snippets which might improve the comment: Returns a normalized representation of the string value suitable for embedding in SQL as a single-quoted string literal. String literals can come directly from the SQL of a query or from rewrites like constant folding, so we generally do not know whether single or double quotes are appropriate for a given value. The SQL standard prescribes single-quoted string literals so we normalize that way. http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java@100 PS7, Line 100: private String getNormalizedValue() { nit: we typically use /* */ style comment for class and function comments http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/main/java/org/apache/impala/analysis/StringLiteral.java@101 PS7, Line 101: final int lengthOfValue = value_.length(); len? http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/test/java/org/apache/impala/analysis/ToSqlTest.java File fe/src/test/java/org/apache/impala/analysis/ToSqlTest.java: http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/test/java/org/apache/impala/analysis/ToSqlTest.java@468 PS7, Line 468: public void escapeStringLiteralTest() { normalizeStringLiteralsTest http://gerrit.cloudera.org:8080/#/c/8818/7/fe/src/test/java/org/apache/impala/analysis/ToSqlTest.java@471 PS7, Line 471: testToSql("select \"\\\\'\"", "SELECT '\\\\\\''"); add a few tests with single quotes that show they are not transformed http://gerrit.cloudera.org:8080/#/c/8818/6/tests/query_test/test_queries.py File tests/query_test/test_queries.py: http://gerrit.cloudera.org:8080/#/c/8818/6/tests/query_test/test_queries.py@310 PS6, Line 310: > I agree with your suggestion. ToSqlTest mainly checks the problem. By the w I'm ok with leaving some E2E tests. Imo they belong in views-ddl.test since the user-visible bug is really around creating/using views, and the toSql() issue is already covered by ToSqlTest unit tests. -- To view, visit http://gerrit.cloudera.org:8080/8818 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ibc4b5f5d8ffaa8feb96a466959427a04b3b06fec Gerrit-Change-Number: 8818 Gerrit-PatchSet: 7 Gerrit-Owner: Kim Jin Chul <jinc...@gmail.com> Gerrit-Reviewer: Alex Behm <alex.b...@cloudera.com> Gerrit-Reviewer: Gabor Kaszab <gaborkas...@cloudera.com> Gerrit-Reviewer: Jim Apple <jbapple-imp...@apache.org> Gerrit-Reviewer: Kim Jin Chul <jinc...@gmail.com> Gerrit-Reviewer: Thomas Tauber-Marshall <tmarsh...@cloudera.com> Gerrit-Reviewer: Tim Armstrong <tarmstr...@cloudera.com> Gerrit-Comment-Date: Thu, 18 Jan 2018 00:20:30 +0000 Gerrit-HasComments: Yes