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 push function concat, concat_ws, datediff, year, day, unix_timestamp down to TiFlash. #1588

Closed
wants to merge 14 commits into from

Conversation

LittleFall
Copy link
Contributor

What problem does this PR solve?

Issue Number: partially #1480

What is changed and how it works?

already supported:

  • month, ifnull

opened

  • year, day, unix_timestamp

supported

  • concat, concat_ws, datediff

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn: need update push down docs
  • Need to cherry-pick to the release branch: 4.0, 5.0

Check List

Tests

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

Release note

  • Support function year, day, unix_timestamp, concat, concat_ws, datediff push down to TiFlash

@leiysky leiysky added the type/bugfix This PR fixes a bug. label Mar 19, 2021
@LittleFall LittleFall requested a review from leiysky March 19, 2021 06:39
@leiysky
Copy link
Contributor

leiysky commented Mar 19, 2021

Maybe add some unit tests or integration tests(port from TiDB)?

@@ -1303,13 +1303,11 @@ class FunctionTiDBTimestampDiff : public IFunction
throw Exception("First argument for function " + getName() + " (unit) must be String",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

if(!checkDataType<DataTypeMyDateTime>(removeNullable(arguments[1]).get()) &&
!checkDataType<DataTypeMyDate>(removeNullable(arguments[1]).get()))
if(!removeNullable(arguments[1])->isDateOrDateTime())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this? DataTypeDate, DataTypeDatetime is not supported yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we assume that this TiDB Function will never accept the non-TiDB datatype?

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we won't build DataTypeDate or DataTypeDateTime arguments for this function anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

But we do not delete DataTypeDate and DataTypeDateTime, I think it's better to throw error explicitly if the function does not support DataTypeDate and DataTypeDateTime

throw Exception("Second argument for function " + getName() + " must be MyDate or MyDateTime",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

if(!checkDataType<DataTypeMyDateTime>(removeNullable(arguments[2]).get()) &&
!checkDataType<DataTypeMyDate>(removeNullable(arguments[2]).get()))
if(!removeNullable(arguments[2])->isDateOrDateTime())
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
@LittleFall
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

Should add some tests for this.

@@ -1303,13 +1303,11 @@ class FunctionTiDBTimestampDiff : public IFunction
throw Exception("First argument for function " + getName() + " (unit) must be String",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

if(!checkDataType<DataTypeMyDateTime>(removeNullable(arguments[1]).get()) &&
!checkDataType<DataTypeMyDate>(removeNullable(arguments[1]).get()))
if(!removeNullable(arguments[1])->isDateOrDateTime())
Copy link
Contributor

Choose a reason for hiding this comment

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

But we do not delete DataTypeDate and DataTypeDateTime, I think it's better to throw error explicitly if the function does not support DataTypeDate and DataTypeDateTime

@LittleFall LittleFall changed the title Support some function push down. Support push function concat, concat_ws, datediff, year, day, unix_timestamp down to TiFlash. Apr 1, 2021
@LittleFall LittleFall added type/new-feature Issue or PR for new feature and removed type/bugfix This PR fixes a bug. labels Apr 1, 2021
@LittleFall LittleFall closed this Jun 3, 2021
@LittleFall LittleFall deleted the function-pushdown branch June 4, 2021 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/new-feature Issue or PR for new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants