Skip to content

Add timediff function - #1505

Merged
imay merged 2 commits into
apache:masterfrom
HangyuanLiu:add-timediff
Jul 23, 2019
Merged

Add timediff function#1505
imay merged 2 commits into
apache:masterfrom
HangyuanLiu:add-timediff

Conversation

@HangyuanLiu

@HangyuanLiuHangyuanLiu commented Jul 18, 2019

Copy link
Copy Markdown
Contributor

Add timediff function

#1428

@chenhao7253886

Copy link
Copy Markdown
Contributor

I think that you need't import a new udf type to implement timediff.

Comment threadgensrc/script/gen_functions.py Outdated
'VARCHAR': 'string_val',
'DATE': 'datetime_val',
'DATETIME': 'datetime_val',
'TIME': 'datetime_val',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's better to use bigint_val

}
// no need to check upper bound
break;
case TIME:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it is not fit to add type TIME in IntLiteral

case TYPE_DATETIME:
case TYPE_TIME: {
char buf[64];
const DateTimeValue* time_val = (const DateTimeValue*)(item);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think use bigint to represent time in memory?

@HangyuanLiu
HangyuanLiuforce-pushed the add-timediff branch 2 times, most recently from 403f208 to 4fb06b4CompareJuly 22, 2019 03:17
Comment threadbe/src/exprs/literal.cpp Outdated
_value.datetime_val.from_date_str(
node.date_literal.value.c_str(), node.date_literal.value.size());
break;
case TYPE_TIME:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reuse TYPE_DOUBLE

public:
static void init();

static BooleanVal cast_to_boolean_val(FunctionContext*, const DoubleVal&);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can only support time to double and to string

Comment threadbe/src/runtime/raw_value.cpp Outdated
break;
}

case TYPE_TIME:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be the same as TYPE_DOUBLE

buf_ret = _row_buffer->push_double(*static_cast<double*>(item));
break;

case TYPE_TIME: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can write a function to do this to avoid write this many times

case INT:
return "IntVal";
case BIGINT:
case TIME:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why BIGINT?

compatibilityMatrix[DECIMALV2.ordinal()][DECIMAL.ordinal()] = DECIMALV2;

compatibilityMatrix[HLL.ordinal()][HLL.ordinal()] = HLL;
compatibilityMatrix[TIME.ordinal()][TIME.ordinal()] = TIME;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you should add more relation between time and other types

@HangyuanLiu
HangyuanLiuforce-pushed the add-timediff branch 7 times, most recently from e649d62 to 92d7b85CompareJuly 23, 2019 03:56

@imayimay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@imay
imay merged commit 4aedaea into apache:masterJul 23, 2019
morningman pushed a commit to baidu-doris/incubator-doris that referenced this pull request Jul 28, 2019
morningman pushed a commit to baidu-doris/incubator-doris that referenced this pull request Jul 28, 2019
@imayimay mentioned this pull request Sep 26, 2019
@HangyuanLiu
HangyuanLiu deleted the add-timediff branch December 25, 2019 02:06
swjtu-zhanglei pushed a commit to swjtu-zhanglei/incubator-doris that referenced this pull request Jul 25, 2023
Sign up for freeto 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.

3 participants

@HangyuanLiu@chenhao7253886@imay