Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for array_repeat array function #1205

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
updated the return type of expression, have to fix tests
jatin510 committed Jan 18, 2025
commit cb904df7c9aabfe996b5fb7ae2043d0cda2bf735
3 changes: 2 additions & 1 deletion native/core/src/execution/planner.rs
Original file line number Diff line number Diff line change
@@ -771,7 +771,8 @@ impl PhysicalPlanner {
self.create_expr(expr.left.as_ref().unwrap(), Arc::clone(&input_schema))?;
let count_expr =
self.create_expr(expr.right.as_ref().unwrap(), Arc::clone(&input_schema))?;
let return_type = src_expr.data_type(&input_schema)?;
let element_type = src_expr.data_type(&input_schema)?;
let return_type = DataType::List(Arc::new(Field::new("item", element_type, true)));
let args = vec![Arc::clone(&src_expr), Arc::clone(&count_expr)];

let datafusion_array_repeat = array_repeat_udf();
21 changes: 9 additions & 12 deletions spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
Original file line number Diff line number Diff line change
@@ -2559,18 +2559,15 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
makeParquetFileAllTypes(path, dictionaryEnabled, 10000)
spark.read.parquet(path.toString).createOrReplaceTempView("t1")

// checkSparkAnswerAndOperator(sql("SELECT array_repeat(_2, 3) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(5, _2) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(_2, null) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(2, null) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(null, 3) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(null, _3) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(_2, 0) from t1"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(_2, -1) from t1"))
checkSparkAnswerAndOperator(sql("SELECT array_repeat(8, 5) from t1"))
checkSparkAnswerAndOperator(sql("SELECT array_repeat(_8, 2) from t1"))
checkSparkAnswerAndOperator(sql("SELECT array_repeat(true, 3) from t1"))
checkSparkAnswerAndOperator(sql("SELECT array_repeat(1.5, 2) from t1"))
checkSparkAnswerAndOperator(
sql("SELECT array_repeat(array(_2,_3), _2) from t1 where _2 is null"))
// checkSparkAnswerAndOperator(
// sql("SELECT array_repeat(_3, 0) from t1 where _3 is not null"))
// checkSparkAnswerAndOperator(
// sql("SELECT array_repeat(_3, 2) from t1 where _3 is not null"))
// checkSparkAnswerAndOperator(sql("SELECT array_repeat(_2, 2) from t1 where _2 is null"))
// checkSparkAnswerAndOperator(
// sql("SELECT array_repeat(case when _2 = _3 THEN _8 ELSE null END, 2) from t1"))
}
}
}