This is an automated email from the ASF dual-hosted git repository.
zhli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new c780dd0dc [VL] Enable bitwise_and, bitwise_not, bitwise_or,
bitwise_xor for tinyint & int (#5150)
c780dd0dc is described below
commit c780dd0dccd2e62a82d2c4f5a53e4d309357ab26
Author: Zhen Li <[email protected]>
AuthorDate: Fri Mar 29 15:38:52 2024 +0800
[VL] Enable bitwise_and, bitwise_not, bitwise_or, bitwise_xor for tinyint &
int (#5150)
[VL] Enable bitwise_and, bitwise_not, bitwise_or, bitwise_xor for tinyint &
int.
---
.../execution/ScalarFunctionsValidateSuite.scala | 35 ++++++++++++++++++++++
.../functions/RegistrationAllFunctions.cc | 2 ++
cpp/velox/substrait/SubstraitParser.cc | 4 +++
3 files changed, 41 insertions(+)
diff --git
a/backends-velox/src/test/scala/io/glutenproject/execution/ScalarFunctionsValidateSuite.scala
b/backends-velox/src/test/scala/io/glutenproject/execution/ScalarFunctionsValidateSuite.scala
index 2419d288b..e91d64c6e 100644
---
a/backends-velox/src/test/scala/io/glutenproject/execution/ScalarFunctionsValidateSuite.scala
+++
b/backends-velox/src/test/scala/io/glutenproject/execution/ScalarFunctionsValidateSuite.scala
@@ -613,4 +613,39 @@ class ScalarFunctionsValidateSuite extends
FunctionsValidateTest {
}
}
+ test("bitwise_and") {
+ runQueryAndCompare(
+ "select cast(l_orderkey as tinyint) & cast(l_partkey as tinyint)," +
+ " cast(l_orderkey as int) & cast(l_partkey as int), l_orderkey &
l_partkey" +
+ " from lineitem") {
+ checkOperatorMatch[ProjectExecTransformer]
+ }
+ }
+
+ test("bitwise_not") {
+ runQueryAndCompare(
+ "select ~(cast(l_orderkey as tinyint)), ~(cast(l_orderkey as int)),
~l_orderkey" +
+ " from lineitem") {
+ checkOperatorMatch[ProjectExecTransformer]
+ }
+ }
+
+ test("bitwise_or") {
+ runQueryAndCompare(
+ "select cast(l_orderkey as tinyint) | cast(l_partkey as tinyint)," +
+ " cast(l_orderkey as int) | cast(l_partkey as int), l_orderkey |
l_partkey" +
+ " from lineitem") {
+ checkOperatorMatch[ProjectExecTransformer]
+ }
+ }
+
+ test("bitwise_xor") {
+ runQueryAndCompare(
+ "select cast(l_orderkey as tinyint) ^ cast(l_partkey as tinyint)," +
+ " cast(l_orderkey as int) ^ cast(l_partkey as int), l_orderkey ^
l_partkey" +
+ " from lineitem") {
+ checkOperatorMatch[ProjectExecTransformer]
+ }
+ }
+
}
diff --git a/cpp/velox/operators/functions/RegistrationAllFunctions.cc
b/cpp/velox/operators/functions/RegistrationAllFunctions.cc
index a11963446..8f8b82d8d 100644
--- a/cpp/velox/operators/functions/RegistrationAllFunctions.cc
+++ b/cpp/velox/operators/functions/RegistrationAllFunctions.cc
@@ -25,6 +25,7 @@
#include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/functions/prestosql/window/WindowFunctionsRegistration.h"
+#include "velox/functions/sparksql/Bitwise.h"
#include "velox/functions/sparksql/Hash.h"
#include "velox/functions/sparksql/Register.h"
#include "velox/functions/sparksql/aggregates/Register.h"
@@ -61,6 +62,7 @@ void registerFunctionOverwrite() {
velox::exec::registerFunctionCallToSpecialForm(
RowConstructorWithNullCallToSpecialForm::kRowConstructorWithNull,
std::make_unique<RowConstructorWithNullCallToSpecialForm>());
+ velox::functions::sparksql::registerBitwiseFunctions("spark_");
}
} // namespace
diff --git a/cpp/velox/substrait/SubstraitParser.cc
b/cpp/velox/substrait/SubstraitParser.cc
index 71966a0b3..0354ee4cb 100644
--- a/cpp/velox/substrait/SubstraitParser.cc
+++ b/cpp/velox/substrait/SubstraitParser.cc
@@ -394,6 +394,10 @@ std::unordered_map<std::string, std::string>
SubstraitParser::substraitVeloxFunc
{"named_struct", "row_constructor"},
{"bit_or", "bitwise_or_agg"},
{"bit_and", "bitwise_and_agg"},
+ {"bitwise_and", "spark_bitwise_and"},
+ {"bitwise_not", "spark_bitwise_not"},
+ {"bitwise_or", "spark_bitwise_or"},
+ {"bitwise_xor", "spark_bitwise_xor"},
{"murmur3hash", "hash_with_seed"},
{"modulus", "remainder"},
{"date_format", "format_datetime"},
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]