Skip to content

[CALCITE-6185] Support date format#3611

Closed
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:6185
Closed

[CALCITE-6185] Support date format#3611
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:6185

Conversation

@caicancai
Copy link
Member

@caicancai caicancai commented Jan 4, 2024

Copy link
Contributor

@tanclary tanclary left a comment

Choose a reason for hiding this comment

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

If you rebase on main it might be easier to tell what exactly is being added in this PR (at least for someone like me who reviews based on "Files changed").

@caicancai caicancai force-pushed the 6185 branch 3 times, most recently from 2c6d68d to b042e5c Compare January 6, 2024 07:58
@caicancai caicancai changed the title [CALCITE-6185] Support more date format [CALCITE-6185] Support century function format Jan 6, 2024
@caicancai
Copy link
Member Author

caicancai commented Jan 6, 2024

I initially wanted to support timezone, but according to my tests, there seems to be no unified standard for timezone.
Don't Merge

Support CC format format and add tests (pg)
Consider supporting timezone,
full lower case day name(day) pg
lower case day name(dy) pg

@caicancai caicancai requested a review from tanclary January 6, 2024 11:53
@caicancai caicancai force-pushed the 6185 branch 2 times, most recently from deec335 to 96b7123 Compare January 6, 2024 16:09
@caicancai caicancai changed the title [CALCITE-6185] Support century function format [CALCITE-6185] Support date format Jan 6, 2024
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@XuQianJin-Stars
Copy link
Contributor

Please merge after this pr #3609.

import static org.apache.calcite.util.format.FormatElementEnum.YY;
import static org.apache.calcite.util.format.FormatElementEnum.YYYY;
import static org.apache.calcite.util.format.FormatElementEnum.day;
import static org.apache.calcite.util.format.FormatElementEnum.dy;
Copy link
Contributor

Choose a reason for hiding this comment

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

The imports here should be in alphabetical order.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it, but it will report an error. It seems that there is a restriction on the upper and lower case order.
import static org.apache.calcite.util.format.FormatElementEnum.*; ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't checkstyle complain if the imports are in the wrong order?

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly checkstyle is using a different collation (e.g. different treatment of upper/lower case, spaces, underscores). Do whatever makes checkstyle happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Easiest thing is to make the enum constants upper-case.

@caicancai caicancai marked this pull request as ready for review January 8, 2024 10:45
* @see FormatModels#DEFAULT
*/
public enum FormatElementEnum implements FormatElement {
CC("cc", "century (2 digits) (the twenty-first century starts on 2001-01-01)") {
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 the commit message should probably be more descriptive, I wasn't sure what Support date format meant until I reviewed the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

I won't even review a PR until the jira case has a good description of its goals. Sounds pedantic but it's very pragmatic.

This jira case also needs to say which functions these date formats are supported in. Changes to FormatElementEnum are not useful unless they are surfaced in functions.

sb.append(work.eeeeFormat.format(date));
}
},
day("eeee", "The full lower case day name") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Enum constants should be all uppercase I believe.
https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

assertThat(ts, hasToString("Tuesday"));
}

@Test void testday() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Test name should be camelcase

assertThat(ts, hasToString("Tue"));
}

@Test void testdy() {
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

}

@Test void testCC() {
final String date = "2014-09-30T10:00:00Z";
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding to the end of the file why don't we make these alphabetical

@caicancai
Copy link
Member Author

caicancai commented Jan 9, 2024

Thanks everyone.
I thought about it and found that my jira is indeed irregular. I am sorry for causing trouble to the community. I will improve my jira later.

@caicancai caicancai marked this pull request as draft January 9, 2024 06:00
@caicancai caicancai closed this Jan 9, 2024
@caicancai
Copy link
Member Author

I will open this pr after clarifying the overall architecture and code structure of calcite. If I feel that this pr has a pr at that time,

@caicancai caicancai deleted the 6185 branch February 15, 2024 12:03
Sign up for free to 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.

5 participants