> On June 30, 2014, 11:49 p.m., Aditya Kishore wrote: > > exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java, > > lines 1125-1135 > > <https://reviews.apache.org/r/21614/diff/4/?file=614798#file614798line1125> > > > > These are UTF-8 encoded strings. 1 char != 1 byte. > > > > @Test > > public void test4() { > > String original = "???"; > > String reverse = new StringBuilder(original).reverse().toString(); > > System.out.println(original); > > > > System.out.println(Arrays.toString(original.getBytes(Charsets.UTF_8))); > > System.out.println(reverse); > > System.out.println(Arrays.toString(reverse.getBytes(Charsets.UTF_8))); > > } > > > > output: > > ------- > > ??? > > [-32, -92, -82, -32, -92, -90, -32, -92, -88] > > ??? > > [-32, -92, -88, -32, -92, -90, -32, -92, -82] > > > > Aditya Kishore wrote: > Seems reviewboard has trouble handling non-English characters in the > comment section. The string is suppose to be "MADAN" ("???") in Hindi.
Fixed and added new test scenario in testcase. - Yash ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/21614/#review47027 ----------------------------------------------------------- On July 5, 2014, 12:27 p.m., Yash Sharma wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/21614/ > ----------------------------------------------------------- > > (Updated July 5, 2014, 12:27 p.m.) > > > Review request for drill, Aditya Kishore and Mehant Baid. > > > Repository: drill-git > > > Description > ------- > > Added implementation for String functions: > - ascii(str) > - toascii(str, srcEncoding) > - btrim(str, chars) > - char(int) > - repeat(str, numOfTimes) > - reverse(str) > > > Diffs > ----- > > > exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionUtil.java > 16ff8f2 > > exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java > 92ac56f > > exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java > 3f9ba5e > exec/java-exec/src/test/resources/functions/string/testStringFuncs.json > PRE-CREATION > > Diff: https://reviews.apache.org/r/21614/diff/ > > > Testing > ------- > > Yes. > > $ mvn test -Dtest=TestStringFunctions#testNewStringFuncs > ------------------------------- > ACTUAL EXPECTED > ------------------------------- > 97 97 > 65 65 > -32 -32 > A A > trim trim > Peace Peace Peace Peace Peace Peace > ????? ????? ????? ????? ????? ????? ????? ????? > katcit katcit > âpple âpple > ------------------------------- > > > SQLLINE TESTS: > > SELECT employee_id, toascii('âpple','ISO-8859-1') as ascii_str FROM > cp.`employee.json` limit 10; > +-------------+------------+ > | employee_id | ascii_str | > +-------------+------------+ > | 1 | âpple | > | 2 | âpple | > | 4 | âpple | > | 5 | âpple | > | 6 | âpple | > | 7 | âpple | > | 8 | âpple | > | 9 | âpple | > | 10 | âpple | > | 11 | âpple | > +-------------+------------+ > 10 rows selected (0.315 seconds) > > > SELECT employee_id, first_name as first_name, reverse(first_name) as > revrese_name, repeat(first_name,2) as repeat_name FROM cp.`employee.json` > limit 10; > +-------------+------------+--------------+-------------+ > | employee_id | first_name | revrese_name | repeat_name | > +-------------+------------+--------------+-------------+ > | 1 | Sheri | irehS | SheriSheri | > | 2 | Derrick | kcirreD | DerrickDerrick | > | 4 | Michael | leahciM | MichaelMichael | > | 5 | Maya | ayaM | MayaMaya | > | 6 | Roberta | atreboR | RobertaRoberta | > | 7 | Rebecca | accebeR | RebeccaRebecca | > | 8 | Kim | miK | KimKim | > | 9 | Brenda | adnerB | BrendaBrenda | > | 10 | Darren | nerraD | DarrenDarren | > | 11 | Jonathan | nahtanoJ | JonathanJonatha | > +-------------+------------+--------------+-------------+ > > > SELECT employee_id, first_name as first_name, ascii(first_name) as ascii_ch, > chr(65) as char_65 FROM cp.`employee.json` limit 10; > +-------------+------------+------------+------------+ > | employee_id | first_name | ascii_ch | char_65 | > +-------------+------------+------------+------------+ > | 1 | Sheri | 83 | A | > | 2 | Derrick | 68 | A | > | 4 | Michael | 77 | A | > | 5 | Maya | 77 | A | > | 6 | Roberta | 82 | A | > | 7 | Rebecca | 82 | A | > | 8 | Kim | 75 | A | > | 9 | Brenda | 66 | A | > | 10 | Darren | 68 | A | > | 11 | Jonathan | 74 | A | > +-------------+------------+------------+------------+ > > > Thanks, > > Yash Sharma > >
