You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xuzifu666 (via GitHub)" <gi...@apache.org> on 2025/01/28 09:17:26 UTC
[PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
xuzifu666 opened a new pull request, #4172:
URL: https://github.com/apache/calcite/pull/4172
Currently Spark Hive hex and unhex function not introduce for calcite, need to support it.
jira: https://issues.apache.org/jira/browse/CALCITE-6805
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1935143842
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
Review Comment:
You need to add a test for numbers
```
scala> val df = spark.sql("select hex('1')")
df: org.apache.spark.sql.DataFrame = [hex(1): string]
scala> df.show()
+------+
|hex(1)|
+------+
| 31|
+------+
scala> val df = spark.sql("select hex('0')")
df: org.apache.spark.sql.DataFrame = [hex(0): string]
scala> df.show()
+------+
|hex(0)|
+------+
| 30|
+------+
scala> val df = spark.sql("select hex('-1')")
df: org.apache.spark.sql.DataFrame = [hex(-1): string]
scala> df.show()
+-------+
|hex(-1)|
+-------+
| 2D31|
+-------+
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621006542
> Thanks @xuzifu666 . I left another minor comment, but overall lgtm. One small detail: there's a typo on the Jira title, PR title and (most importantly) on the commit message (`Libaray` instead of `Library`), could you please fix that?
Very Thanks for @rubenada review , had addressed comments and fix the title of pr and commit, PTAL~
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2620995612
Thanks @xuzifu666 . I left another minor comment, but overall lgtm.
One small detail: there's a typo on the Jira title, PR title and (most importantly) on the commit message (`Libaray` instead of `Library`), could you please fix that?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621665915
@caicancai had addressed comments,PTAL
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1935135602
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
@xuzifu666 feel free to open a separate Jira ticket (related to this one) to cover the `unhex` implementation, even if you don't plan to work on it right away.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621067249
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [90.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2620765139
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [90.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933840054
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
Review Comment:
Done, had added jira link for it. thanks @caicancai
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934961212
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
Yes, unhex maybe had some problem in hive and spark side, after discussion I remove the implement of unhex from this pr, this pr change to support hex only.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934962973
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -364,6 +364,21 @@ public static String toHex(ByteString byteString) {
return Hex.encodeHexString(byteString.getBytes());
}
+ /** SQL HEX(varchar) function. */
+ public static String hex(String value) {
+ return Hex.encodeHexString(value.getBytes(UTF_8));
Review Comment:
Thanks, UTF-8 seems ok for all, I had consider other funciton such md5/base32.. function also use UTF8 and CI is OK.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933278030
##########
core/src/main/java/org/apache/calcite/util/BuiltInMethod.java:
##########
@@ -435,6 +435,8 @@ public enum BuiltInMethod {
FROM_BASE64(SqlFunctions.class, "fromBase64", String.class),
TO_BASE32(SqlFunctions.class, "toBase32", String.class),
FROM_BASE32(SqlFunctions.class, "fromBase32", String.class),
+ HEX(SqlFunctions.class, "hex", String.class),
+ UNHEX(SqlFunctions.class, "hex", String.class),
Review Comment:
Thanks, addressed @rubenada
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1890,6 +1890,26 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding
OperandTypes.BINARY,
SqlFunctionCategory.STRING);
+ /**
+ * The "HEX(string)" function; converts {@code string} into a hexadecimal varchar.
+ */
+ @LibraryOperator(libraries = {HIVE, SPARK})
+ public static final SqlFunction HEX =
+ SqlBasicFunction.create("HEX",
+ ReturnTypes.VARCHAR_NULLABLE,
+ OperandTypes.STRING,
+ SqlFunctionCategory.STRING);
+
+ /**
+ * The "HEX(string)" function; converts {@code string} into a hexadecimal varchar.
Review Comment:
ditto
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934185151
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
Are you sure that unhex(0) is equal to null? I tested it in Spark and the result is [00]
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2624457233
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2623462936
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933840054
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
Review Comment:
Had add spark and hive function link in jira.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 closed pull request #4172: [CALCITE-6805] Support hex and unhex for Hive and Spark Library
URL: https://github.com/apache/calcite/pull/4172
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1932392240
##########
core/src/main/java/org/apache/calcite/util/BuiltInMethod.java:
##########
@@ -435,6 +435,8 @@ public enum BuiltInMethod {
FROM_BASE64(SqlFunctions.class, "fromBase64", String.class),
TO_BASE32(SqlFunctions.class, "toBase32", String.class),
FROM_BASE32(SqlFunctions.class, "fromBase32", String.class),
+ HEX(SqlFunctions.class, "hex", String.class),
+ UNHEX(SqlFunctions.class, "hex", String.class),
Review Comment:
Wrong method name (copy-paste error from previous line)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934185151
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
`unhex(0) == [00]` not null
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2620742547
@rubenada Thanks for your review, all comments had addressed, PTAL
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933815460
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
done
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
Review Comment:
done
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1932392820
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1890,6 +1890,26 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding
OperandTypes.BINARY,
SqlFunctionCategory.STRING);
+ /**
+ * The "HEX(string)" function; converts {@code string} into a hexadecimal varchar.
+ */
+ @LibraryOperator(libraries = {HIVE, SPARK})
+ public static final SqlFunction HEX =
+ SqlBasicFunction.create("HEX",
+ ReturnTypes.VARCHAR_NULLABLE,
+ OperandTypes.STRING,
+ SqlFunctionCategory.STRING);
+
+ /**
+ * The "HEX(string)" function; converts {@code string} into a hexadecimal varchar.
Review Comment:
Wrong javadoc description (copy-paste error from previous method)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai merged PR #4172:
URL: https://github.com/apache/calcite/pull/4172
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621073406
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [90.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621660961
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621637604
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933840054
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
Review Comment:
Done, had added jira link for it.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2621868863
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4172&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4172&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4172&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4172)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933471831
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -359,6 +359,22 @@ public static ByteString fromHex(String hex) {
}
}
+ /** SQL HEX(varchar) function. */
Review Comment:
Done
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934961212
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
Yes, unhex maybe had some problem in hive and spark side, after discussion I remove the implement of unhex from this pr, this pr change to support hex only and issue also changed too.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Libaray [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933462900
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -359,6 +359,22 @@ public static ByteString fromHex(String hex) {
}
}
+ /** SQL HEX(varchar) function. */
Review Comment:
nit: could you please put the new methods after the existing `toHex` method definition? I'd like to keep "related" methods (fromHex/toHex) right next to each other (similarly to the new ones hex/unhex).
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1933533786
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
Review Comment:
Add jira link
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+ }
+
+ @Test void testUnHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+ f0.checkFails("^unhex('')^",
+ "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("unhex('616263')",
+ "abc",
+ "VARCHAR NOT NULL");
+ f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("unhex(cast(null as varbinary))");
Review Comment:
You need to add more tests
e.g.
```
scala> val df = spark.sql("select unhex(null)")
df: org.apache.spark.sql.DataFrame = [unhex(NULL): binary]
scala> df.show()
+-----------+
|unhex(NULL)|
+-----------+
| null|
+-----------+
scala> val df = spark.sql("select unhex(0)")
df: org.apache.spark.sql.DataFrame = [unhex(0): binary]
scala> df.show()
+--------+
|unhex(0)|
+--------+
| [00]|
+--------+
scala> val df = spark.sql("select unhex(-1)")
df: org.apache.spark.sql.DataFrame = [unhex(-1): binary]
scala> df.show()
+---------+
|unhex(-1)|
+---------+
| null|
+---------+
```
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f0.forEachLibrary(libraries, consumer);
}
+ @Test void testHex() {
+ SqlOperatorFixture sqlOperatorFixture = fixture();
+ final SqlOperatorFixture f0 = sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+ f0.checkFails("^hex('')^",
+ "No match found for function signature HEX\\(<CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("hex('abc')",
+ "616263",
+ "VARCHAR NOT NULL");
+ f.checkString("hex('')", "", "VARCHAR NOT NULL");
+ f.checkNull("hex(cast(null as varbinary))");
Review Comment:
above all
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2623746014
LGTM, @caicancai waiting for you approval too before finalize the merge.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex and unhex for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934191023
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -364,6 +364,21 @@ public static String toHex(ByteString byteString) {
return Hex.encodeHexString(byteString.getBytes());
}
+ /** SQL HEX(varchar) function. */
+ public static String hex(String value) {
+ return Hex.encodeHexString(value.getBytes(UTF_8));
Review Comment:
I'm not sure if it's UTF-8, but I'd accept it if it's compatible with all tests
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2624464847
Just a small suggestion, you don't need to compress and submit every time, just compress and submit after the final approval.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6805] Support hex function for Hive and Spark Library [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4172:
URL: https://github.com/apache/calcite/pull/4172#issuecomment-2624395545
> Need to add some tests
Thanks for reminder, I had add more tests for it~ @caicancai
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org