From commits-return-15898-archive-asf-public=cust-asf.ponee.io@pinot.apache.org Mon Feb 3 23:24:26 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1D04018067C for ; Tue, 4 Feb 2020 00:24:26 +0100 (CET) Received: (qmail 4128 invoked by uid 500); 3 Feb 2020 23:24:25 -0000 Mailing-List: contact commits-help@pinot.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pinot.apache.org Delivered-To: mailing list commits@pinot.apache.org Received: (qmail 4084 invoked by uid 99); 3 Feb 2020 23:24:25 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2020 23:24:25 +0000 From: GitBox To: commits@pinot.apache.org Subject: [GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5033: Set alias name in resultTable schema names Message-ID: <158077226545.5271.2113443799171990507.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Mon, 03 Feb 2020 23:24:25 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Jackie-Jiang commented on a change in pull request #5033: Set alias name in resultTable schema names URL: https://github.com/apache/incubator-pinot/pull/5033#discussion_r374398649 ########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java ########## @@ -178,7 +188,46 @@ public BrokerResponseNative reduceOnDataTable(BrokerRequest brokerRequest, } DataTableReducer dataTableReducer = ResultReducerFactory.getResultReducer(brokerRequest); - dataTableReducer.reduceAndSetResults(tableName, cachedDataSchema, dataTableMap, brokerResponseNative, brokerMetrics); + dataTableReducer + .reduceAndSetResults(tableName, cachedDataSchema, dataTableMap, brokerResponseNative, brokerMetrics); + updateAliasToSchemaName(brokerRequest, brokerResponseNative); return brokerResponseNative; } -} + + private static void updateAliasToSchemaName(BrokerRequest brokerRequest, BrokerResponseNative brokerResponseNative) { + if (brokerRequest.getPinotQuery() == null) { + return; + } + QueryOptions queryOptions = new QueryOptions(brokerRequest.getQueryOptions()); + if (!queryOptions.isResponseFormatSQL()) { + return; + } + DataSchema dataSchema = brokerResponseNative.getResultTable().getDataSchema(); + List selectList = brokerRequest.getPinotQuery().getSelectList(); + String[] columnNames = dataSchema.getColumnNames(); + int selectListSize = selectList.size(); + if (columnNames.length != selectListSize) { + return; + } + for (int i = 0; i < selectListSize; i++) { + Function selectFunc = selectList.get(i).getFunctionCall(); + if (selectFunc != null && selectFunc.getOperator() + .equalsIgnoreCase(SqlKind.AS.toString())) { + String aliasName = null; Review comment: We should not perform sanity check here, but when we compile the query. At this point, alias should always exist and should always be identifier. ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org For additional commands, e-mail: commits-help@pinot.apache.org