Skip to content

Conversation

@Jefffrey
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Prefer to avoid user_defined for consistency in function definitions.

What changes are included in this PR?

Refactor signature of power away from user_defined.

Are these changes tested?

Existing tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Nov 27, 2025
Comment on lines +304 to +310
// Null propagation
if base_type.is_null() || exponent_type.is_null() {
let return_type = self.return_type(&[base_type, exponent_type])?;
return Ok(ExprSimplifyResult::Simplified(lit(
ScalarValue::Null.cast_to(&return_type)?
)));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to what we do for log:

// Null propagation
if arg_types.iter().any(|dt| dt.is_null()) {
return Ok(ExprSimplifyResult::Simplified(lit(
ScalarValue::Null.cast_to(&return_type)?
)));
}

}

#[test]
fn test_power_f64() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these to SLTs

@Jefffrey Jefffrey marked this pull request as ready for review November 27, 2025 12:02
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Jefffrey -- this looks great to me

fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let base = &args.args[0].to_array(args.number_rows)?;
let exponent = &args.args[1];
let [base, exponent] = take_function_args(self.name(), &args.args)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Jefffrey Jefffrey added this pull request to the merge queue Dec 16, 2025
Merged via the queue into apache:main with commit fc88240 Dec 16, 2025
27 checks passed
@Jefffrey Jefffrey deleted the refactor-pow branch December 16, 2025 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants