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 user level sql function #1095

Merged
merged 34 commits into from
Apr 12, 2023
Merged

Support user level sql function #1095

merged 34 commits into from
Apr 12, 2023

Conversation

pythonbrad
Copy link
Contributor

@pythonbrad pythonbrad commented Feb 17, 2023

Linked to

#660

TODO

  • Show function statement
  • Drop function statement
  • Create function statement

Example

CREATE FUNCTION nothing();
CREATE FUNCTION hello() RETURN 'hello!';
CREATE FUNCTION add(x int) RETURN x+1;
CREATE FUNCTION div(a int, b int) RETURN a/b;
CREATE FUNCTION incr(a int, b int default 1) RETURN (SELECT bar from foo);
SELECT nothing();
SELECT incr(1);
SHOW FUNCTIONS;

@coveralls
Copy link

coveralls commented Feb 17, 2023

Pull Request Test Coverage Report for Build 4677170930

  • 526 of 539 (97.59%) changed or added relevant lines in 20 files are covered.
  • 28 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.02%) to 98.874%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core/src/executor/alter/function.rs 33 34 97.06%
core/src/executor/execute.rs 18 20 90.0%
core/src/store/function.rs 10 20 50.0%
Files with Coverage Reduction New Missed Lines %
core/src/ast/function.rs 1 99.87%
core/src/ast/mod.rs 1 99.83%
core/src/plan/expr/function.rs 1 99.55%
core/src/executor/aggregate/mod.rs 2 86.53%
core/src/executor/evaluate/function.rs 2 98.93%
core/src/executor/evaluate/stateless.rs 2 94.01%
core/src/executor/execute.rs 19 91.86%
Totals Coverage Status
Change from base Build 4636876365: 0.02%
Covered Lines: 43042
Relevant Lines: 43532

💛 - Coveralls

@ever0de ever0de added the enhancement New feature or request label Mar 1, 2023
@pythonbrad pythonbrad force-pushed the patch_sql branch 3 times, most recently from 0cee14f to 0522471 Compare March 9, 2023 12:04
@pythonbrad pythonbrad marked this pull request as ready for review March 9, 2023 12:29
core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/store/function.rs Outdated Show resolved Hide resolved
core/src/store/function.rs Outdated Show resolved Hide resolved
core/src/store/function.rs Outdated Show resolved Hide resolved
core/src/store/function.rs Outdated Show resolved Hide resolved
storages/memory-storage/tests/memory_storage.rs Outdated Show resolved Hide resolved
@pythonbrad pythonbrad requested review from panarch and removed request for ever0de and devgony March 15, 2023 21:55
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.

Wow, now it's really close to the completion!

With some comments, it would be nice that we can add a few more tests to reach uncovered lines.
ref. you can ignore await uncovered lines which we cannot make it work.
https://coveralls.io/builds/57904316
image

core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/translate/ddl.rs Outdated Show resolved Hide resolved
core/src/translate/mod.rs Outdated Show resolved Hide resolved
@panarch panarch requested a review from ever0de March 18, 2023 08:01
@pythonbrad pythonbrad force-pushed the patch_sql branch 2 times, most recently from 8f3c4f5 to b225b2a Compare April 7, 2023 09:21
@@ -1,4 +1,5 @@
mod bigdecimal_ext;
pub mod function;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub mod function;
mod function;

core/src/translate/function.rs Show resolved Hide resolved
Cargo.lock Outdated Show resolved Hide resolved
Comment on lines +110 to +111
expected_minimum: usize,
expected_maximum: usize,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expected_minimum: usize,
expected_maximum: usize,
expected_range: Range<usize>

Copy link
Member

Choose a reason for hiding this comment

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

@ever0de current custom function does not support open range so it would be better to use expected_minimum & expected_maximum.
Range can describe (3..) or (..=4) like open ranges that are not supported by our custom function args

core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
core/src/executor/evaluate/mod.rs Outdated Show resolved Hide resolved
@panarch panarch self-requested a review April 8, 2023 12:07
@pythonbrad pythonbrad marked this pull request as draft April 8, 2023 13:04
@pythonbrad
Copy link
Contributor Author

@ever0de , finally i done a rebase. I apply reviews.

@pythonbrad pythonbrad marked this pull request as ready for review April 8, 2023 13:16
@ever0de ever0de self-requested a review April 8, 2023 13:17
@ever0de
Copy link
Member

ever0de commented Apr 9, 2023

Could you please confirm and apply CI?

@pythonbrad
Copy link
Contributor Author

@panarch, i fixed it

test-suite/src/function/custom.rs Outdated Show resolved Hide resolved
core/src/data/function.rs Outdated Show resolved Hide resolved
core/src/data/function.rs Outdated Show resolved Hide resolved
core/src/ast/ddl.rs Outdated Show resolved Hide resolved
core/src/ast/function.rs Outdated Show resolved Hide resolved
@panarch panarch self-requested a review April 11, 2023 04:46
test-suite/src/function/custom.rs Outdated Show resolved Hide resolved
@panarch panarch self-requested a review April 12, 2023 08:20
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.

Ok now it's really the time to ship this awesome new feature to the main!
Looks all great 👍 👍 👍
Thanks a lot!

@panarch panarch merged commit 7dd2a91 into gluesql:main Apr 12, 2023
8 checks passed
@pythonbrad pythonbrad deleted the patch_sql branch April 30, 2023 19:45
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.

None yet

4 participants