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

Implement Rand function #1063

Merged
merged 3 commits into from
Jan 17, 2023
Merged

Implement Rand function #1063

merged 3 commits into from
Jan 17, 2023

Conversation

pythonbrad
Copy link
Contributor

resolve #593

@coveralls
Copy link

coveralls commented Jan 15, 2023

Pull Request Test Coverage Report for Build 3932940113

  • 105 of 106 (99.06%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 98.512%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core/src/executor/evaluate/mod.rs 4 5 80.0%
Totals Coverage Status
Change from base Build 3861901309: -0.004%
Covered Lines: 37678
Relevant Lines: 38247

💛 - Coveralls

@devgony devgony added the enhancement New feature or request label Jan 15, 2023
Copy link
Member

@panarch panarch left a comment

Choose a reason for hiding this comment

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

I left some very nit comments.
Everything else looks nice.

Thanks a lot :)
also thanks for adding rand support to ast_builder.

Comment on lines 279 to 282
let expr = match expr {
Some(v) => Some(eval(v)?),
None => None,
};
Copy link
Member

Choose a reason for hiding this comment

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

nit. there is eval_opt sugar closure function. so you can use

let expr = eval_opt(expr.as_ref())?;

Comment on lines 450 to 452
pub fn rand<'a, T: Into<ExprNode<'a>>>(expr: T) -> ExprNode<'a> {
ExprNode::Function(Box::new(FunctionNode::Rand(Some(expr.into()))))
}
Copy link
Member

Choose a reason for hiding this comment

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

Currently, using ast builder we cannot use random function without seed.
It would be better to take Option<ExprNode<'a>> rather than Into<ExprNode<'a>>.
Like.. rtrim and ltrim.

fyi.
For now, when we use Option<ExprNode<'a>>, then Into is not supported yet.

@pythonbrad
Copy link
Contributor Author

Thanks for your review.

Copy link
Member

@panarch panarch left a comment

Choose a reason for hiding this comment

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

Looks all good. Thanks a lot 👍

@panarch panarch merged commit 868a648 into gluesql:main Jan 17, 2023
@pythonbrad pythonbrad deleted the rand branch February 13, 2023 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support Rand() function
4 participants