gortiz commented on code in PR #11327: URL: https://github.com/apache/pinot/pull/11327#discussion_r1312786674
########## pinot-query-planner/src/main/java/org/apache/pinot/query/validate/Validator.java: ########## @@ -34,4 +42,85 @@ public Validator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader // TODO: support BABEL validator. Currently parser conformance is set to use BABEL. super(opTab, catalogReader, typeFactory, Config.DEFAULT.withSqlConformance(SqlConformanceEnum.LENIENT)); } + + /** + * Expand the star in the select list. + * Pinot table schema has all columns along with virtual columns. + * We don't want to include virtual columns in the select * query + * + * @param selectList Select clause to be expanded + * @param select Query + * @param includeSystemVars Whether to include system variables + * @return Expanded select list + */ + @Override + public SqlNodeList expandStar( + SqlNodeList selectList, + SqlSelect select, + boolean includeSystemVars) { + SqlNodeList expandedSelectList = super.expandStar(selectList, select, includeSystemVars); + RelRecordType validatedNodeType = (RelRecordType) getValidatedNodeType(select); + + List<String> selectedVirtualColumns = getSelectedVirtualColumns(select); + // ExpandStar will add a field for each column in the table, but we don't want to include the virtual columns + List<SqlNode> newSelectList = new ArrayList<>(); + List<RelDataTypeField> newFieldList = new ArrayList<>(); + for (int i = 0; i < expandedSelectList.size(); i++) { + SqlNode node = expandedSelectList.get(i); + if (node instanceof SqlIdentifier) { + String columnName = getColumnName((SqlIdentifier) node); + if (isVirtualColumn(columnName)) { + // If the virtual column is selected, remove it from the list of selected virtual columns + if (!selectedVirtualColumns.remove(columnName)) { Review Comment: We had a regression (we think that it was added [here](https://github.com/apache/pinot/pull/11457)) that was not detected because we didn't have this tests -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org