Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions native/core/src/execution/jni_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use datafusion_spark::function::math::hex::SparkHex;
use datafusion_spark::function::math::width_bucket::SparkWidthBucket;
use datafusion_spark::function::string::char::CharFunc;
use datafusion_spark::function::string::concat::SparkConcat;
use datafusion_spark::function::string::elt::SparkElt;
use futures::poll;
use futures::stream::StreamExt;
use jni::objects::JByteBuffer;
Expand Down Expand Up @@ -400,6 +401,7 @@ fn register_datafusion_spark_function(session_ctx: &SessionContext) {
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkWidthBucket::default()));
session_ctx.register_udf(ScalarUDF::new_from_impl(MapFromEntries::default()));
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkCrc32::default()));
session_ctx.register_udf(ScalarUDF::new_from_impl(SparkElt::default()));
}

/// Prepares arrow arrays for output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ object QueryPlanSerde extends Logging with CometExprShim {
classOf[ConcatWs] -> CometConcatWs,
classOf[Concat] -> CometConcat,
classOf[Contains] -> CometScalarFunction("contains"),
classOf[Elt] -> CometScalarFunction("elt"),
classOf[EndsWith] -> CometScalarFunction("ends_with"),
classOf[InitCap] -> CometInitCap,
classOf[Length] -> CometLength,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ class CometStringExpressionSuite extends CometTestBase {
}
}

test("elt") {
withParquetTable(Seq((1, "a", "b", "c"), (2, "x", "y", "z"), (3, "p", "q", "r")), "tbl") {
checkSparkAnswerAndOperator("SELECT elt(_1, _2, _3, _4) FROM tbl")
checkSparkAnswerAndOperator("SELECT elt(1, 'hello', 'world') FROM tbl")
checkSparkAnswerAndOperator("SELECT elt(NULL, 'a', 'b') FROM tbl")
}
}

test("split string basic") {
withSQLConf("spark.comet.expression.StringSplit.allowIncompatible" -> "true") {
withParquetTable((0 until 5).map(i => (s"value$i,test$i", i)), "tbl") {
Expand Down