[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support
XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support URL: https://github.com/apache/calcite/pull/1865#discussion_r399242294 ## File path: core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java ## @@ -5192,6 +5192,25 @@ private void checkNullOperand(SqlTester tester, String op) { "0700789c4bad48cc2dc84905000bc002ed", "VARBINARY NOT NULL"); } + @Test public void testUncompress() { +SqlTester sqlTester = tester(SqlLibrary.MYSQL); +sqlTester.checkNull("UNCOMPRESS(NULL)"); +sqlTester.checkString("UNCOMPRESS(x'')", "", "VARCHAR"); + +sqlTester.checkNull("UNCOMPRESS(x'1233')"); + +sqlTester.checkString("UNCOMPRESS(COMPRESS('test'))", +"test", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'1000789c4b4c44050033980611')", +"", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'0600789c2b4ecc2dc849050008de0283' )", +"sample", "VARCHAR"); + sqlTester.checkString("UNCOMPRESS(x'0700789c4bad48cc2dc84905000bc002ed')", +"example", "VARCHAR"); + } Review comment: > Done :) My fault, I listed an example. You need to increase the corresponding error message capture. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support
XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support URL: https://github.com/apache/calcite/pull/1865#discussion_r399001523 ## File path: core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java ## @@ -5192,6 +5192,25 @@ private void checkNullOperand(SqlTester tester, String op) { "0700789c4bad48cc2dc84905000bc002ed", "VARBINARY NOT NULL"); } + @Test public void testUncompress() { +SqlTester sqlTester = tester(SqlLibrary.MYSQL); +sqlTester.checkNull("UNCOMPRESS(NULL)"); +sqlTester.checkString("UNCOMPRESS(x'')", "", "VARCHAR"); + +sqlTester.checkNull("UNCOMPRESS(x'1233')"); + +sqlTester.checkString("UNCOMPRESS(COMPRESS('test'))", +"test", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'1000789c4b4c44050033980611')", +"", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'0600789c2b4ecc2dc849050008de0283' )", +"sample", "VARCHAR"); + sqlTester.checkString("UNCOMPRESS(x'0700789c4bad48cc2dc84905000bc002ed')", +"example", "VARCHAR"); + } Review comment: Can add tests based on error? `sqlTester.checkFails("UNCOMPRESS('test')","(?s).*Only ByteString.*", true);` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support
XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support URL: https://github.com/apache/calcite/pull/1865#discussion_r398304749 ## File path: core/src/main/java/org/apache/calcite/runtime/CompressionFunctions.java ## @@ -62,4 +65,21 @@ public static ByteString compress(String data) { } } + /** + * MySql Decompression is based on zlib. + * https://docs.oracle.com/javase/8/docs/api/java/util/zip/Inflater.html;>Inflater + * is used to implement decompression. + */ + public static String uncompress(ByteString data) { +try { + if (data == null || data.length() == 0) { Review comment: > For `data.length==0`, is it possible to be an empty string? ``` mysql> select uncompress(null),uncompress(''); +--++ | uncompress(null) | uncompress('') | +--++ | NULL || +--++ 1 row in set (0.00 sec) ``` It should be an empty string 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support
XuQianJin-Stars commented on a change in pull request #1865: [CALCITE-3648] MySQL UNCOMPRESS function support URL: https://github.com/apache/calcite/pull/1865#discussion_r396856276 ## File path: core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java ## @@ -5192,6 +5192,23 @@ private void checkNullOperand(SqlTester tester, String op) { "0700789c4bad48cc2dc84905000bc002ed", "VARBINARY NOT NULL"); } + @Test public void testUncompress() { +SqlTester sqlTester = tester(SqlLibrary.MYSQL); +sqlTester.checkNull("UNCOMPRESS(NULL)"); +sqlTester.checkNull("UNCOMPRESS(x'')"); + +sqlTester.checkString("UNCOMPRESS(COMPRESS('test'))", +"test", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'1000789c4b4c44050033980611')", +"", "VARCHAR"); + +sqlTester.checkString("UNCOMPRESS(x'0600789c2b4ecc2dc849050008de0283' )", Review comment: I think in order to cover the test, we need to add a non-ByteString type test. 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: us...@infra.apache.org With regards, Apache Git Services