You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/01/18 06:18:26 UTC

[GitHub] [calcite] XuQianJin-Stars opened a new pull request #1768: [CALCITE-3704] Implement STRCMP function

XuQianJin-Stars opened a new pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768
 
 
   As illustrated in [CALCITE-3704](https://issues.apache.org/jira/browse/CALCITE-3704)
   MySQL strcmp() function is used to compare two strings. It returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
   
   Syntax:
   STRCMP (expr1, expr2)

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] danny0405 commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r376301607
 
 

 ##########
 File path: site/_docs/reference.md
 ##########
 @@ -2350,6 +2350,7 @@ semantics.
 | m o p | SOUNDEX(string)                            | Returns the phonetic representation of *string*; throws if *string* is encoded with multi-byte encoding such as UTF-8
 | m | SPACE(integer)                                 | Returns a string of *integer* spaces; returns an empty string if *integer* is less than 1
 | o | SUBSTR(string, position [, substringLength ]) | Returns a portion of *string*, beginning at character *position*, *substringLength* characters long. SUBSTR calculates lengths using characters as defined by the input character set
+| m | STRCMP(string, string)                         | Returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
 
 Review comment:
   Is the `defined order` customizable ?

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] amaliujia commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r368362265
 
 

 ##########
 File path: site/_docs/reference.md
 ##########
 @@ -2350,6 +2350,7 @@ semantics.
 | m o p | SOUNDEX(string)                            | Returns the phonetic representation of *string*; throws if *string* is encoded with multi-byte encoding such as UTF-8
 | m | SPACE(integer)                                 | Returns a string of *integer* spaces; returns an empty string if *integer* is less than 1
 | o | SUBSTR(string, position [, substringLength ]) | Returns a portion of *string*, beginning at character *position*, *substringLength* characters long. SUBSTR calculates lengths using characters as defined by the input character set
+| m | STRCMP(string, string)                         | Returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
 
 Review comment:
   What does the `the defined order` mean? lexicographical order?

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-578072990
 
 
   Can we create a table function like tumble function??

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] chunweilei merged pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
chunweilei merged pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768
 
 
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
XuQianJin-Stars commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r376834082
 
 

 ##########
 File path: site/_docs/reference.md
 ##########
 @@ -2350,6 +2350,7 @@ semantics.
 | m o p | SOUNDEX(string)                            | Returns the phonetic representation of *string*; throws if *string* is encoded with multi-byte encoding such as UTF-8
 | m | SPACE(integer)                                 | Returns a string of *integer* spaces; returns an empty string if *integer* is less than 1
 | o | SUBSTR(string, position [, substringLength ]) | Returns a portion of *string*, beginning at character *position*, *substringLength* characters long. SUBSTR calculates lengths using characters as defined by the input character set
+| m | STRCMP(string, string)                         | Returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
 
 Review comment:
   > Can the Java `compareTo` take the charSet into account ?
   
           String chinese = "中文";
           String gbkChinese = new String(chinese.getBytes("GBK"), "ISO-8859-1");//转换成gbk编码
           String unicodeChinese = new String(gbkChinese.getBytes("ISO-8859-1"), "GBK");//java内部编码
           System.out.println(unicodeChinese);//中文
           String utf8Chinese = new String(unicodeChinese.getBytes("UTF-8"), "ISO-8859-1");//utf--8编码
           System.out.println(utf8Chinese);//乱码
           unicodeChinese = new String(utf8Chinese.getBytes("ISO-8859-1"), "UTF-8");//java内部编码
           System.out.println(unicodeChinese);//中文
   
           String str1 = "中文";
           String str2 = "中文1";
           String str3 = null;
   
           System.out.println((int) Math.signum(str1.compareTo(chinese)));
           System.out.println((int) Math.signum(str2.compareTo(chinese)));
           System.out.println(str1.compareTo(chinese));
           System.out.println(str2.compareTo(chinese));
   
   This test `compareTo` is work.

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 edited a comment on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 edited a comment on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576111404
 
 
   CALCITE-3748 
   I have made some changes in table functions in apache calcite but i am unable to connnect to the udf table function and run the query??
   
   select * from table(s.multiplication(5,6,5));

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
XuQianJin-Stars commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r376338376
 
 

 ##########
 File path: site/_docs/reference.md
 ##########
 @@ -2350,6 +2350,7 @@ semantics.
 | m o p | SOUNDEX(string)                            | Returns the phonetic representation of *string*; throws if *string* is encoded with multi-byte encoding such as UTF-8
 | m | SPACE(integer)                                 | Returns a string of *integer* spaces; returns an empty string if *integer* is less than 1
 | o | SUBSTR(string, position [, substringLength ]) | Returns a portion of *string*, beginning at character *position*, *substringLength* characters long. SUBSTR calculates lengths using characters as defined by the input character set
+| m | STRCMP(string, string)                         | Returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
 
 Review comment:
   > Is the `defined order` customizable ?
   
   I noticed that this function of mysql can change the character set. as follows:
   mysql> SET @s1 = _utf8mb4 'x' COLLATE utf8mb4_0900_ai_ci;
   mysql> SET @s2 = _utf8mb4 'X' COLLATE utf8mb4_0900_ai_ci;
   mysql> SET @s3 = _utf8mb4 'x' COLLATE utf8mb4_0900_as_cs;
   mysql> SET @s4 = _utf8mb4 'X' COLLATE utf8mb4_0900_as_cs;
   mysql> SELECT STRCMP(@s1, @s2), STRCMP(@s3, @s4);
   +------------------+------------------+
   | STRCMP(@s1, @s2) | STRCMP(@s3, @s4) |
   +------------------+------------------+
   |                0 |               -1 |
   +------------------+------------------+

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] XuQianJin-Stars commented on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
XuQianJin-Stars commented on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-598685208
 
 
   hi, @danny0405 @chunweilei Thank you very much.

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 edited a comment on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 edited a comment on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576111404
 
 
   
   I have made some changes in table functions in apache calcite but i am unable to connnect to the udf table function and run the query??
   
   select * from table(s.multiplication(5,6,5));

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] amaliujia commented on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
amaliujia commented on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576112359
 
 
   @swathi858 Can you create a Jira and describe what you found there?

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] chunweilei commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r368262446
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -368,6 +368,11 @@ public static String space(int n) {
     return repeat(" ", n);
   }
 
+  /** SQL STRCMP(String,String) function. */
+  public static Integer strcmp(String s0, String s1) {
+    return (int) Math.signum(s1.compareTo(s0));
 
 Review comment:
   IMO, the return type should be `int`.

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 removed a comment on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 removed a comment on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576111404
 
 
   
   I have made some changes in table functions in apache calcite but i am unable to connnect to the udf table function and run the query??
   
   select * from table(s.multiplication(5,6,5));

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576524805
 
 
   SELECT * FROM TABLE(Ramp(3, 4))
   when i enter this query in sqlline in apache calcite i am getting error as
   No match found for function signature RAMP(, ) (state=,code=0)
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
swathi858 commented on issue #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#issuecomment-576111404
 
 
   I have made some changes in table functions in apache calcite but i am unable to connnect to the udf table function and run the query??
   
   select * from table(s.multiplication(5,6,5));

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [calcite] danny0405 commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #1768: [CALCITE-3704] Implement STRCMP function
URL: https://github.com/apache/calcite/pull/1768#discussion_r376683872
 
 

 ##########
 File path: site/_docs/reference.md
 ##########
 @@ -2350,6 +2350,7 @@ semantics.
 | m o p | SOUNDEX(string)                            | Returns the phonetic representation of *string*; throws if *string* is encoded with multi-byte encoding such as UTF-8
 | m | SPACE(integer)                                 | Returns a string of *integer* spaces; returns an empty string if *integer* is less than 1
 | o | SUBSTR(string, position [, substringLength ]) | Returns a portion of *string*, beginning at character *position*, *substringLength* characters long. SUBSTR calculates lengths using characters as defined by the input character set
+| m | STRCMP(string, string)                         | Returns 0 if both of the strings are same and returns -1 when the first argument is smaller than the second according to the defined order and 1 when the second one is smaller the first one.
 
 Review comment:
   Can the Java `compareTo` take the charSet into account ?

----------------------------------------------------------------
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


With regards,
Apache Git Services