You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/06 14:05:19 UTC

[GitHub] [hive] nrg4878 commented on a change in pull request #1814: HIVE-15820: comment at the head of beeline -e

nrg4878 commented on a change in pull request #1814:
URL: https://github.com/apache/hive/pull/1814#discussion_r552640050



##########
File path: beeline/src/test/org/apache/hive/beeline/TestCommands.java
##########
@@ -30,21 +30,35 @@
 
   @Test
   public void testLinesEndingWithComments() {
-    int[] escape = {-1};
-    assertEquals("show tables;", removeComments("show tables;",escape));
-    assertEquals("show tables;", removeComments("show tables; --comments",escape));
-    assertEquals("show tables;", removeComments("show tables; -------comments",escape));
-    assertEquals("show tables;", removeComments("show tables; -------comments;one;two;three;;;;",escape));
-    assertEquals("show", removeComments("show-- tables; -------comments",escape));
-    assertEquals("show", removeComments("show --tables; -------comments",escape));
-    assertEquals("s", removeComments("s--how --tables; -------comments",escape));
-    assertEquals("", removeComments("-- show tables; -------comments",escape));
+    assertEquals("show tables;", removeComments("show tables;"));
+    assertEquals("show tables;", removeComments("show tables; --comments"));
+    assertEquals("show tables;", removeComments("show tables; -------comments"));
+    assertEquals("show tables;", removeComments("show tables; -------comments;one;two;three;;;;"));
+    assertEquals("show", removeComments("show-- tables; -------comments"));
+    assertEquals("show", removeComments("show --tables; -------comments"));
+    assertEquals("s", removeComments("s--how --tables; -------comments"));
+    assertEquals("", removeComments("-- show tables; -------comments"));
 
-    assertEquals("\"show tables\"", removeComments("\"show tables\" --comments",escape));
-    assertEquals("\"show --comments tables\"", removeComments("\"show --comments tables\" --comments",escape));
-    assertEquals("\"'show --comments' tables\"", removeComments("\"'show --comments' tables\" --comments",escape));
-    assertEquals("'show --comments tables'", removeComments("'show --comments tables' --comments",escape));
-    assertEquals("'\"show --comments tables\"'", removeComments("'\"show --comments tables\"' --comments",escape));
+    assertEquals("\"show tables\"", removeComments("\"show tables\" --comments"));
+    assertEquals("\"show --comments tables\"", removeComments("\"show --comments tables\" --comments"));
+    assertEquals("\"'show --comments' tables\"", removeComments("\"'show --comments' tables\" --comments"));
+    assertEquals("'show --comments tables'", removeComments("'show --comments tables' --comments"));
+    assertEquals("'\"show --comments tables\"'", removeComments("'\"show --comments tables\"' --comments"));
+
+    assertEquals("show tables;", removeComments("--comments\nshow tables;"));
+    assertEquals("show tables;", removeComments("--comments\nshow tables; --comments"));
+    assertEquals("show tables;", removeComments("--comments\nshow tables; -------comments"));
+    assertEquals("show tables;", removeComments("--comments\nshow tables; -------comments;one;two;three;;;;"));
+    assertEquals("show", removeComments("--comments\nshow-- tables; -------comments"));
+    assertEquals("show", removeComments("--comments\nshow --tables; -------comments"));
+    assertEquals("s", removeComments("--comments\ns--how --tables; -------comments"));
+    assertEquals("", removeComments("--comments\n-- show tables; -------comments"));
+
+    assertEquals("\"show tables\"", removeComments("--comments\n\"show tables\" --comments"));
+    assertEquals("\"show --comments tables\"", removeComments("--comments\n\"show --comments tables\" --comments"));
+    assertEquals("\"'show --comments' tables\"", removeComments("--comments\n\"'show --comments' tables\" --comments"));
+    assertEquals("'show --comments tables'", removeComments("--comments\n'show --comments tables' --comments"));
+    assertEquals("'\"show --comments tables\"'", removeComments("--comments\n'\"show --comments tables\"' --comments"));

Review comment:
       Could you please add a test scenario where a multiline query strings has comments in between fragments of query? just as an example
   "select col1,
   --partitioned year column
   year,
   --partitioned month column
   month,
   --partitioned date column
   date
   from test_table
   where
   --for a particular user
   username = 'foo';"
   
   should return something equivalent to
   "select col1, year, month, date from test_table where username = 'foo';"




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org