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 to unparse ScalarValue::TimestampNanosecond to String #10984

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

goldmedal
Copy link
Contributor

Which issue does this PR close?

Closes #10796 .

Rationale for this change

What changes are included in this PR?

Instead of array_value_to_string, I just follow how to convert datetime type because I found the timestamp string converted by the arrow formatter would be

1970-01-01T00:00:00.000010001

but I think the result generated by datetime::to_string is more suitable for SQL

1970-01-01 00:00:00.000010001

Are these changes tested?

Yes

Are there any user-facing changes?

@github-actions github-actions bot added the sql SQL Planner label Jun 18, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @goldmedal -- this is a nice contribution

Comment on lines 836 to 843
Ok(ast::Expr::Cast {
kind: ast::CastKind::Cast,
expr: Box::new(ast::Expr::Value(ast::Value::SingleQuotedString(
result.to_string(),
))),
data_type: ast::DataType::Timestamp(None, TimezoneInfo::None),
format: None,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this code is repeated in both branches -- we could probably avoid the replication

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @alamb, for reminding me of this point. I forgot to refactor this part.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

❤️

@alamb alamb merged commit fbf7934 into apache:main Jun 18, 2024
23 checks passed
@goldmedal goldmedal deleted the feature/10796-TimestampNanosecond-to-sql branch June 19, 2024 02:06
@goldmedal
Copy link
Contributor Author

Thanks @alamb

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

Successfully merging this pull request may close these issues.

Implement ScalarValue::TimestampNanosecond -> String Support
2 participants