You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/02/19 15:55:26 UTC

[GitHub] [ignite] ygerzhedovich opened a new pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

ygerzhedovich opened a new pull request #8815:
URL: https://github.com/apache/ignite/pull/8815


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ygerzhedovich commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r586613391



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -62,6 +63,22 @@
     /** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
     private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
 
+    /** **/
+    private static final EnumSet<SqlKind> HUMAN_READABLE_ALIASES_FOR;
+
+    static {
+        EnumSet<SqlKind> kinds = EnumSet.noneOf(SqlKind.class);
+
+        kinds.addAll(SqlKind.AGGREGATE);
+        kinds.addAll(SqlKind.BINARY_ARITHMETIC);
+        kinds.addAll(SqlKind.FUNCTION);
+
+        kinds.add(SqlKind.CEIL);
+        kinds.add(SqlKind.FLOOR);
+
+        HUMAN_READABLE_ALIASES_FOR = kinds;

Review comment:
       good catch!
   fixed first two suggestions




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ygerzhedovich commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r586750475



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -62,6 +63,22 @@
     /** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
     private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
 
+    /** **/
+    private static final EnumSet<SqlKind> HUMAN_READABLE_ALIASES_FOR;
+
+    static {
+        EnumSet<SqlKind> kinds = EnumSet.noneOf(SqlKind.class);
+
+        kinds.addAll(SqlKind.AGGREGATE);
+        kinds.addAll(SqlKind.BINARY_ARITHMETIC);
+        kinds.addAll(SqlKind.FUNCTION);
+
+        kinds.add(SqlKind.CEIL);
+        kinds.add(SqlKind.FLOOR);
+
+        HUMAN_READABLE_ALIASES_FOR = kinds;

Review comment:
       added limit length for aliases




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ygerzhedovich commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r579656938



##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java
##########
@@ -264,6 +267,16 @@ public QueryChecker returns(Object... res) {
         return CoreMatchers.containsString("IgniteUnionAll(all=[" + all + "])");
     }
 
+    /** */
+    public QueryChecker columnNames(String... columns) {

Review comment:
       I can't imagine a case when it required override %)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] korlov42 commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
korlov42 commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r579650947



##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java
##########
@@ -303,6 +316,13 @@ public void check() {
 
         FieldsQueryCursor<List<?>> cur = cursors.get(0);
 
+        if(expectedColumnNames != null) {
+            assertEquals("numer of columns are different", expectedColumnNames.size(), cur.getColumnsCount());

Review comment:
       ```suggestion
               assertEquals("number of columns are different", expectedColumnNames.size(), cur.getColumnsCount());
   ```

##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/AggregatesIntegrationTest.java
##########
@@ -102,6 +108,21 @@ public void countOfNonNumericField() throws InterruptedException {
             .check();
     }
 
+    private void createAndPopulateTable() {

Review comment:
       missing javadoc

##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java
##########
@@ -264,6 +267,16 @@ public QueryChecker returns(Object... res) {
         return CoreMatchers.containsString("IgniteUnionAll(all=[" + all + "])");
     }
 
+    /** */
+    public QueryChecker columnNames(String... columns) {

Review comment:
       I would prefer to override expected column names each time this method invoked. I can hardly imagine using it like this:
   ```
   assertQuery("select c1, c2, c3, c4 from my_table")
       .columnNames("c1", "c2")
       .columnNames("c3", "c4")
       .check()
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ygerzhedovich commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r586613391



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -62,6 +63,22 @@
     /** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
     private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
 
+    /** **/
+    private static final EnumSet<SqlKind> HUMAN_READABLE_ALIASES_FOR;
+
+    static {
+        EnumSet<SqlKind> kinds = EnumSet.noneOf(SqlKind.class);
+
+        kinds.addAll(SqlKind.AGGREGATE);
+        kinds.addAll(SqlKind.BINARY_ARITHMETIC);
+        kinds.addAll(SqlKind.FUNCTION);
+
+        kinds.add(SqlKind.CEIL);
+        kinds.add(SqlKind.FLOOR);
+
+        HUMAN_READABLE_ALIASES_FOR = kinds;

Review comment:
       good catch!
   fixed first two suggestion




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] korlov42 commented on a change in pull request #8815: IGNITE-14157: Return good names for columns related to aggregates

Posted by GitBox <gi...@apache.org>.
korlov42 commented on a change in pull request #8815:
URL: https://github.com/apache/ignite/pull/8815#discussion_r586591597



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -62,6 +63,22 @@
     /** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
     private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
 
+    /** **/
+    private static final EnumSet<SqlKind> HUMAN_READABLE_ALIASES_FOR;
+
+    static {
+        EnumSet<SqlKind> kinds = EnumSet.noneOf(SqlKind.class);
+
+        kinds.addAll(SqlKind.AGGREGATE);
+        kinds.addAll(SqlKind.BINARY_ARITHMETIC);
+        kinds.addAll(SqlKind.FUNCTION);
+
+        kinds.add(SqlKind.CEIL);
+        kinds.add(SqlKind.FLOOR);
+
+        HUMAN_READABLE_ALIASES_FOR = kinds;

Review comment:
       also it seems that case with simple literals is not covered yet.
   
   `select 1, -1, 'some string' from MyTable`
   
   BTW do we plan to limit length of the aliases?

##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -62,6 +63,22 @@
     /** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
     private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
 
+    /** **/
+    private static final EnumSet<SqlKind> HUMAN_READABLE_ALIASES_FOR;
+
+    static {
+        EnumSet<SqlKind> kinds = EnumSet.noneOf(SqlKind.class);
+
+        kinds.addAll(SqlKind.AGGREGATE);
+        kinds.addAll(SqlKind.BINARY_ARITHMETIC);
+        kinds.addAll(SqlKind.FUNCTION);
+
+        kinds.add(SqlKind.CEIL);
+        kinds.add(SqlKind.FLOOR);
+
+        HUMAN_READABLE_ALIASES_FOR = kinds;

Review comment:
       it might be worth to wrap `kinds` with `Collections.unmodifiableSet()`

##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/QueryChecker.java
##########
@@ -303,6 +314,13 @@ public void check() {
 
         FieldsQueryCursor<List<?>> cur = cursors.get(0);
 
+        if(expectedColumnNames != null) {
+            assertEquals("number of columns are different", expectedColumnNames.size(), cur.getColumnsCount());
+
+            for (int i = 0; i < cur.getColumnsCount(); i++)
+                assertEquals(expectedColumnNames.get(i), cur.getFieldName(i));
+        }
+

Review comment:
       ```suggestion
           if (expectedColumnNames != null) {
               List<String> colNames = IntStream.range(0, cur.getColumnsCount())
                   .mapToObj(cur::getFieldName).collect(Collectors.toList());
   
               assertThat("Column names don't match", colNames, equalTo(expectedColumnNames));
           }
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org