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

feat(tianmu): Support for user defined function(#538) #898

Closed
wants to merge 18 commits into from
Closed

feat(tianmu): Support for user defined function(#538) #898

wants to merge 18 commits into from

Conversation

adofsauron
Copy link
Collaborator

@adofsauron adofsauron commented Nov 7, 2022

Summary about this PR

Issue Number: close #538

Tests Check List

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Changelog

  • New Feature
  • Bug Fix
  • Improvement
  • Performance Improvement
  • Build/Testing/CI/CD
  • Documentation
  • Not for changelog (changelog entry is not required)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features

@mergify
Copy link
Contributor

mergify bot commented Nov 7, 2022

This pull request's title should follow requirements next. @adofsauron please check it 👇.

Valid format:

fix(vc): fix sth..... (#3306)
  ^         ^---------^  ^----^
  |         |            |
  |         +            +-> you issue id.
  |         |
  |         +-> Summary in present tense.
  |
  +-------> Type: feat, fix, docs, workflow, style, refactor, test, website, chore

Valid types:

  • feat: new feature for stonedb
  • fix: bug fix for stonedb
  • docs: changes to the documentation
  • workflow: ci/cd in .github
  • refactor: refactoring production code, eg. renaming a variable
  • style: formatting, missing semi colons, etc; no production code change
  • test: adding missing tests, refactoring tests; no production code change
  • website
  • chore: updating grunt tasks etc; no production code change

@mergify
Copy link
Contributor

mergify bot commented Nov 7, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@adofsauron adofsauron changed the title feat(tianmu): Support for custom functions(#538) feat(tianmu): Support for user defined function(#538) Nov 7, 2022
@@ -0,0 +1,257 @@
--source include/have_tianmu.inc

--echo #
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary. you mtr's title has told that.

storage/tianmu/core/query_compile.cpp Show resolved Hide resolved
List_iterator_fast<Item> li(*fields);
for (Item *item = li++; item; item = li++) {
if ((item->type() == Item::Type::FUNC_ITEM) &&
(down_cast<Item_func *>(item)->functype() == Item_func::Functype::FUNC_SP) && (!sl->is_distinct())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic of this part is not ok. How about the field without disctinct ?
The from the if statement, we can not read that fields has not distinct keyword. Therefore, we can not add this option manually. And this option should be added in grammatical procesing stage.

select distinct xxxx 

or

select xxxx

@@ -41,6 +41,19 @@ TwoDimensionalJoiner::~TwoDimensionalJoiner() {

JoinAlgType TwoDimensionalJoiner::ChooseJoinAlgorithm([[maybe_unused]] MultiIndex &mind, Condition &cond) {
auto choose_map_or_hash = ([&tianmu_sysvar_force_hashjoin, &cond] {
{
std::vector<CQTerm *> terms = {&cond[0].attr, &cond[0].val1, &cond[0].val2};
for (auto term : terms) {
Copy link
Contributor

@RingsC RingsC Nov 8, 2022

Choose a reason for hiding this comment

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

refine these lines.

for_each (terms.begin(), terms.end() [&](CQTerm *& tm) {
    if (!tm || !tm->vc) return; 

    Item *item = term->vc->GetItem();
    if (item && (item->type() == Item::Type::FUNC_ITEM) &&
              (down_cast<Item_func *>(item)->functype() == Item_func::Functype::FUNC_SP)) {
           join_type = JoinAlgType::JTYPE_GENERAL;   
});

storage/tianmu/core/query_compile.cpp Show resolved Hide resolved
@adofsauron adofsauron closed this Nov 9, 2022
@mergify
Copy link
Contributor

mergify bot commented Nov 9, 2022

⚠️ The sha of the head commit of this PR conflicts with #913. Mergify cannot evaluate rules on this PR. ⚠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: The Tianmu engine supports user defined function
2 participants