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:
[email protected]