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

Fix CAST(interval day to second as varchar) #9386

Closed

Conversation

mbasmanova
Copy link
Contributor

Summary:
CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes #9384

Differential Revision: D55796600

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 5, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

Copy link

netlify bot commented Apr 5, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit ed8a134
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6610367251718d00086fffc0

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 5, 2024
Summary:

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Differential Revision: D55796600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

@amitkdutta
Copy link
Contributor

Thanks @mbasmanova. velox/expression/tests:velox_expression_test - ExprTest/ParameterizedExprTest.constantToSql is failing. Lets fix that.

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 5, 2024
Summary:

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Differential Revision: D55796600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 5, 2024
Summary:

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Differential Revision: D55796600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

@mbasmanova
Copy link
Contributor Author

@amitkdutta Amit, thank you for review.

velox/expression/tests:velox_expression_test - ExprTest/ParameterizedExprTest.constantToSql is failing. Lets fix that.

Fixed. Would you take another look?

Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

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

@mbasmanova LGTM. Thanks!

[[fallthrough]];
case TypeKind::BIGINT: {
if (vector.type()->isIntervalDayTime()) {
auto intervalVector =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: auto*

INTERVAL_DAY_TIME()->valueToString(inputFlatVector->valueAt(row));
auto writer = exec::StringWriter<>(resultFlatVector, row);
writer.resize(output.size());
std::memcpy(writer.data(), output.data(), output.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ::memcpy

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 5, 2024
Summary:

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Reviewed By: xiaoxmeng

Differential Revision: D55796600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

Summary:

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Reviewed By: xiaoxmeng

Differential Revision: D55796600
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D55796600

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 41bed84.

Copy link

Conbench analyzed the 1 benchmark run on commit 41bed84e.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Joe-Abraham pushed a commit to Joe-Abraham/velox that referenced this pull request Jun 7, 2024
Summary:
Pull Request resolved: facebookincubator#9386

CAST expression used to handle INTERVAL DAY TO SECOND values as BIGINT. This allowed invalid casts (e.g. from varchar, to double, etc.) and produced incorrect results when casting to varchar.

Casting 1 second interval used to return '1000' instead of '0 00:00:01.000'.

Fixes facebookincubator#9384

Reviewed By: xiaoxmeng

Differential Revision: D55796600

fbshipit-source-id: 3d51a8eb18b434315bf9285f58b8f2cdbedca63d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect result from cast(interval day to second as varchar)
4 participants