abhishekagarwal87 commented on code in PR #12431:
URL: https://github.com/apache/druid/pull/12431#discussion_r849275747
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java:
##########
@@ -838,6 +843,20 @@ static ParsedNodes create(final SqlNode node) throws
ValidationException
return new ParsedNodes(explain, druidSqlInsert, query,
ingestionGranularity);
}
+ private static void validateSelectColumnForIngestion(SqlSelect sqlSelect)
throws ValidationException
+ {
+ // Validate that all columns which do some computation in the select
statement are named.
+ // If the column is named, the top level operator should be "AS".
+ for (SqlNode column : sqlSelect.getSelectList().getList()) {
+ if (column instanceof SqlBasicCall) {
+ SqlBasicCall basicCall = (SqlBasicCall) column;
+ if (!"AS".equalsIgnoreCase(basicCall.getOperator().getName())) {
+ throw new ValidationException("Cannot ingest unnamed columns.");
Review Comment:
```suggestion
throw new ValidationException("Cannot ingest unnamed expressions
that do not have an alias. E.g. if you are ingesting \"func(X)\", then you can
rewrite it as \"func(X) as myColumn\"");
```
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java:
##########
@@ -838,6 +843,20 @@ static ParsedNodes create(final SqlNode node) throws
ValidationException
return new ParsedNodes(explain, druidSqlInsert, query,
ingestionGranularity);
}
+ private static void validateSelectColumnForIngestion(SqlSelect sqlSelect)
throws ValidationException
+ {
+ // Validate that all columns which do some computation in the select
statement are named.
+ // If the column is named, the top level operator should be "AS".
+ for (SqlNode column : sqlSelect.getSelectList().getList()) {
+ if (column instanceof SqlBasicCall) {
+ SqlBasicCall basicCall = (SqlBasicCall) column;
+ if (!"AS".equalsIgnoreCase(basicCall.getOperator().getName())) {
+ throw new ValidationException("Cannot ingest unnamed columns.");
Review Comment:
maybe something like above is more helpful?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]