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

Implements Display for PartitionExpr #3985

Closed
killme2008 opened this issue May 18, 2024 · 11 comments · Fixed by #4087
Closed

Implements Display for PartitionExpr #3985

killme2008 opened this issue May 18, 2024 · 11 comments · Fixed by #4087
Labels
C-enhancement Category Enhancements good first issue Good for newcomers

Comments

@killme2008
Copy link
Contributor

What type of enhancement is this?

User experience

What does the enhancement do?

The PartitionExpr doesn't implement Display trait currently, so the partition_expression in partitions table is not user-friendly:

(a) VALUES LESS THAN (PartitionExpr { lhs: Column("a"), op: Lt, rhs: Value(Int32(10)) })

It must be a < 10 instead.

Related code:

pub struct PartitionExpr {

impl Display for PartitionDef {

Implementation challenges

No response

@killme2008 killme2008 added C-enhancement Category Enhancements good first issue Good for newcomers labels May 18, 2024
@Kelvinyu1117
Copy link
Contributor

Can I work on it?

@killme2008
Copy link
Contributor Author

Can I work on it?

Of course.Thank you.

@killme2008
Copy link
Contributor Author

@Kelvinyu1117 Just a friendly reminder, are you still working on this issue? If you require any assistance, please inform us. Thank you.

@Kelvinyu1117
Copy link
Contributor

Yes, I'm working on it, just having some personal stuffs so didnt get chance to dive into the issue.

@Kelvinyu1117
Copy link
Contributor

Kelvinyu1117 commented May 31, 2024

How can I test this feature locally? Do we have any unit tests that involves printing the expressions?

@killme2008
Copy link
Contributor Author

How can I test this feature locally? Do we have any unit tests that involves printing the expressions?

Just run cargo sqlness -t partition, and you will see the different results of the test.

And of course, you must always add a unit test for the PartitionExpr and ParitionExpr, construct an instance and invoke its to_string() function to retrieve the display result, making sure it's expected.

@Kelvinyu1117
Copy link
Contributor

I have run cargo sqlness -t partition, it seems no difference, but my unit test is passed. Am I missing something?
I have opened the PR, perhaps you can have a look and give some suggestions.

@killme2008
Copy link
Contributor Author

I have run cargo sqlness -t partition, it seems no difference, but my unit test is passed. Am I missing something? I have opened the PR, perhaps you can have a look and give some suggestions.

I found the cause. Because we use the debug format of PartitionExpr here

Self::Expr(e) => write!(f, "{:?}", e),

Can you fix it too?

@killme2008
Copy link
Contributor Author

killme2008 commented Jun 2, 2024

Looks like we must change the Display impl for ParitionDef too:

fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {

Just display the partition_bounds, the columns are unnecessary currently. Am I right? @waynexia

You can run cargo sqlness -t partition to see the differences.

@killme2008 killme2008 reopened this Jun 2, 2024
@Kelvinyu1117
Copy link
Contributor

I have run cargo sqlness -t partition, it seems no difference, but my unit test is passed. Am I missing something? I have opened the PR, perhaps you can have a look and give some suggestions.

I found the cause. Because we use the debug format of PartitionExpr here

Self::Expr(e) => write!(f, "{:?}", e),

Can you fix it too?

Sure, let me do that.

@evenyag
Copy link
Contributor

evenyag commented Jun 18, 2024

Can we close this issue now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants