[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-16 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r367728579
 
 

 ##
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
 ##
 @@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils.helix;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.apache.helix.AccessOption;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.HelixPropertyListener;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.pinot.common.config.TableConfig;
+import org.apache.pinot.common.config.TableNameBuilder;
+import org.apache.pinot.common.utils.SchemaUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+
+
+public class TableCache {
+  private static final String PROPERTYSTORE_SCHEMAS_PREFIX = "/SCHEMAS";
+  private static final String PROPERTYSTORE_TABLE_CONFIGS_PREFIX = 
"/CONFIGS/TABLE";
+
+  private ZkHelixPropertyStore _propertyStore;
+  TableConfigChangeListener _tableConfigChangeListener;
+  SchemaChangeListener _schemaChangeListener;
+
+  public TableCache(ZkHelixPropertyStore propertyStore) {
+_propertyStore = propertyStore;
+_schemaChangeListener = new SchemaChangeListener();
+_schemaChangeListener.refresh();
+_tableConfigChangeListener = new TableConfigChangeListener();
+_tableConfigChangeListener.refresh();
+  }
+
+  public String getActualTableName(String tableName) {
+return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
+  }
+
+  public String getActualColumnName(String tableName, String columnName) {
+String schemaName = 
_tableConfigChangeListener._table2SchemaConfigMap.get(tableName.toLowerCase());
+if (schemaName != null) {
+  return _schemaChangeListener.getColumnName(schemaName, columnName);
+}
+return columnName;
+  }
+
+  class TableConfigChangeListener implements IZkChildListener, IZkDataListener 
{
+
+Map _tableConfigMap = new ConcurrentHashMap<>();
+Map _tableNameMap = new ConcurrentHashMap<>();
+Map _table2SchemaConfigMap = new ConcurrentHashMap<>();
+
+public synchronized void refresh() {
+  try {
+//always subscribe first before reading, so that we dont miss any 
changes
+
_propertyStore.subscribeChildChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+
_propertyStore.subscribeDataChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+List children =
+_propertyStore.getChildren(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
null, AccessOption.PERSISTENT);
+if (children != null) {
+  for (ZNRecord znRecord : children) {
+try {
+  TableConfig tableConfig = TableConfig.fromZnRecord(znRecord);
+  String tableNameWithType = tableConfig.getTableName();
+  _tableConfigMap.put(tableNameWithType, tableConfig);
+  String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+  //create case insensitive mapping
+  _tableNameMap.put(tableNameWithType.toLowerCase(), 
tableNameWithType);
+  _tableNameMap.put(rawTableName.toLowerCase(), rawTableName);
+  //create case insensitive mapping between table name and 
schemaName
+  _table2SchemaConfigMap.put(tableNameWithType.toLowerCase(), 
rawTableName);
+  _table2SchemaConfigMap.put(rawTableName.toLowerCase(), 
rawTableName);
+} catch (IOException e) {
+  e.printStackTrace();
+  //ignore
+}
+  }
+}
+  } catch (Exception e) {
+e.printStackTrace();
+//ignore
+  }
+}
+
+@Override
+public void handleChildChange(String s, List list)
+throws Exception {
+  refresh();
+}
+
+  

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-16 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r367725341
 
 

 ##
 File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
 ##
 @@ -335,6 +349,74 @@ public BrokerResponse handleRequest(JsonNode request, 
@Nullable RequesterIdentit
 return brokerResponse;
   }
 
+  private void handleCaseSensitivity(BrokerRequest brokerRequest) {
+String inputTableName = brokerRequest.getQuerySource().getTableName();
+String actualTableName = _tableCache.getActualTableName(inputTableName);
+brokerRequest.getQuerySource().setTableName(actualTableName);
+//fix columns
+if (brokerRequest.getFilterSubQueryMap() != null) {
+  Collection values = 
brokerRequest.getFilterSubQueryMap().getFilterQueryMap().values();
+  for (FilterQuery filterQuery : values) {
+if (filterQuery.getNestedFilterQueryIdsSize() == 0) {
+  String expression = filterQuery.getColumn();
+  filterQuery.setColumn(fixColumnNameCase(actualTableName, 
expression));
+}
+  }
+}
+if (brokerRequest.isSetAggregationsInfo()) {
+  for (AggregationInfo info : brokerRequest.getAggregationsInfo()) {
+if (info.getAggregationParams() != null && !info.getAggregationType()
+.equalsIgnoreCase(AggregationFunctionType.COUNT.getName())) {
+  String column = 
info.getAggregationParams().get(FunctionCallAstNode.COLUMN_KEY_IN_AGGREGATION_INFO);
+  String[] expressions = 
column.split(FunctionCallAstNode.DISTINCT_MULTI_COLUMN_SEPARATOR);
+  String[] newExpressions = new String[expressions.length];
+  for (int i = 0; i < expressions.length; i++) {
+String expression = expressions[i];
+newExpressions[i] = fixColumnNameCase(actualTableName, expression);
+  }
+  String newColumns = 
StringUtil.join(FunctionCallAstNode.DISTINCT_MULTI_COLUMN_SEPARATOR, 
newExpressions);
+  
info.getAggregationParams().put(FunctionCallAstNode.COLUMN_KEY_IN_AGGREGATION_INFO,
 newColumns);
+}
+  }
+  if (brokerRequest.isSetGroupBy()) {
+List expressions = brokerRequest.getGroupBy().getExpressions();
+for (int i = 0; i < expressions.size(); i++) {
+  expressions.set(i, fixColumnNameCase(actualTableName, 
expressions.get(i)));
+}
+  }
+} else {
+  Selection selection = brokerRequest.getSelections();
+  List selectionColumns = selection.getSelectionColumns();
+  for (int i = 0; i < selectionColumns.size(); i++) {
+String expression = selectionColumns.get(i);
+if (!expression.trim().equalsIgnoreCase("*")) {
+  selectionColumns.set(i, fixColumnNameCase(actualTableName, 
expression));
+}
+  }
+}
+  }
+
+  private String fixColumnNameCase(String actualTableName, String expression) {
+TransformExpressionTree rootExpression = 
TransformExpressionTree.compileToExpressionTree(expression);
+LinkedList q = new LinkedList<>();
+q.add(rootExpression);
+while (!q.isEmpty()) {
+  TransformExpressionTree expressionTree = q.pop();
+  switch (expressionTree.getExpressionType()) {
+case FUNCTION:
 
 Review comment:
   I do handle that. am I missing something?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org



[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-15 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r367134830
 
 

 ##
 File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
 ##
 @@ -335,6 +349,74 @@ public BrokerResponse handleRequest(JsonNode request, 
@Nullable RequesterIdentit
 return brokerResponse;
   }
 
+  private void handleCaseSensitivity(BrokerRequest brokerRequest) {
+String inputTableName = brokerRequest.getQuerySource().getTableName();
+String actualTableName = _tableCache.getActualTableName(inputTableName);
+brokerRequest.getQuerySource().setTableName(actualTableName);
+//fix columns
+if (brokerRequest.getFilterSubQueryMap() != null) {
+  Collection values = 
brokerRequest.getFilterSubQueryMap().getFilterQueryMap().values();
+  for (FilterQuery filterQuery : values) {
+if (filterQuery.getNestedFilterQueryIdsSize() == 0) {
 
 Review comment:
   we just need to check the leaf nodes in the filtertree. this check ensures 
that we dont process intermediate nodes like (AND/OR)


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org



[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-14 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r366688484
 
 

 ##
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
 ##
 @@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils.helix;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.apache.helix.AccessOption;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.HelixPropertyListener;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.pinot.common.config.TableConfig;
+import org.apache.pinot.common.config.TableNameBuilder;
+import org.apache.pinot.common.utils.SchemaUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+
+
+public class TableCache {
+  private static final String PROPERTYSTORE_SCHEMAS_PREFIX = "/SCHEMAS";
+  private static final String PROPERTYSTORE_TABLE_CONFIGS_PREFIX = 
"/CONFIGS/TABLE";
+
+  private ZkHelixPropertyStore _propertyStore;
+  TableConfigChangeListener _tableConfigChangeListener;
+  SchemaChangeListener _schemaChangeListener;
+
+  public TableCache(ZkHelixPropertyStore propertyStore) {
+_propertyStore = propertyStore;
+_schemaChangeListener = new SchemaChangeListener();
+_schemaChangeListener.refresh();
+_tableConfigChangeListener = new TableConfigChangeListener();
+_tableConfigChangeListener.refresh();
+  }
+
+  public String getActualTableName(String tableName) {
+return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
+  }
+
+  public String getActualColumnName(String tableName, String columnName) {
+String schemaName = 
_tableConfigChangeListener._table2SchemaConfigMap.get(tableName.toLowerCase());
+if (schemaName != null) {
+  return _schemaChangeListener.getColumnName(schemaName, columnName);
+}
+return columnName;
+  }
+
+  class TableConfigChangeListener implements IZkChildListener, IZkDataListener 
{
+
+Map _tableConfigMap = new ConcurrentHashMap<>();
+Map _tableNameMap = new ConcurrentHashMap<>();
+Map _table2SchemaConfigMap = new ConcurrentHashMap<>();
+
+public synchronized void refresh() {
+  try {
+//always subscribe first before reading, so that we dont miss any 
changes
+
_propertyStore.subscribeChildChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+
_propertyStore.subscribeDataChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+List children =
+_propertyStore.getChildren(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
null, AccessOption.PERSISTENT);
+if (children != null) {
+  for (ZNRecord znRecord : children) {
+try {
+  TableConfig tableConfig = TableConfig.fromZnRecord(znRecord);
+  String tableNameWithType = tableConfig.getTableName();
+  _tableConfigMap.put(tableNameWithType, tableConfig);
+  String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+  //create case insensitive mapping
+  _tableNameMap.put(tableNameWithType.toLowerCase(), 
tableNameWithType);
+  _tableNameMap.put(rawTableName.toLowerCase(), rawTableName);
+  //create case insensitive mapping between table name and 
schemaName
+  _table2SchemaConfigMap.put(tableNameWithType.toLowerCase(), 
rawTableName);
+  _table2SchemaConfigMap.put(rawTableName.toLowerCase(), 
rawTableName);
+} catch (IOException e) {
+  e.printStackTrace();
+  //ignore
+}
+  }
+}
+  } catch (Exception e) {
+e.printStackTrace();
+//ignore
+  }
+}
+
+@Override
+public void handleChildChange(String s, List list)
+throws Exception {
+  refresh();
+}
+
+  

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-14 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r366688368
 
 

 ##
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
 ##
 @@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils.helix;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.apache.helix.AccessOption;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.HelixPropertyListener;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.pinot.common.config.TableConfig;
+import org.apache.pinot.common.config.TableNameBuilder;
+import org.apache.pinot.common.utils.SchemaUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+
+
+public class TableCache {
+  private static final String PROPERTYSTORE_SCHEMAS_PREFIX = "/SCHEMAS";
+  private static final String PROPERTYSTORE_TABLE_CONFIGS_PREFIX = 
"/CONFIGS/TABLE";
+
+  private ZkHelixPropertyStore _propertyStore;
+  TableConfigChangeListener _tableConfigChangeListener;
+  SchemaChangeListener _schemaChangeListener;
+
+  public TableCache(ZkHelixPropertyStore propertyStore) {
+_propertyStore = propertyStore;
+_schemaChangeListener = new SchemaChangeListener();
+_schemaChangeListener.refresh();
+_tableConfigChangeListener = new TableConfigChangeListener();
+_tableConfigChangeListener.refresh();
+  }
+
+  public String getActualTableName(String tableName) {
+return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
+  }
+
+  public String getActualColumnName(String tableName, String columnName) {
+String schemaName = 
_tableConfigChangeListener._table2SchemaConfigMap.get(tableName.toLowerCase());
+if (schemaName != null) {
+  return _schemaChangeListener.getColumnName(schemaName, columnName);
+}
+return columnName;
+  }
+
+  class TableConfigChangeListener implements IZkChildListener, IZkDataListener 
{
+
+Map _tableConfigMap = new ConcurrentHashMap<>();
+Map _tableNameMap = new ConcurrentHashMap<>();
+Map _table2SchemaConfigMap = new ConcurrentHashMap<>();
+
+public synchronized void refresh() {
+  try {
+//always subscribe first before reading, so that we dont miss any 
changes
+
_propertyStore.subscribeChildChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+
_propertyStore.subscribeDataChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+List children =
+_propertyStore.getChildren(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
null, AccessOption.PERSISTENT);
+if (children != null) {
+  for (ZNRecord znRecord : children) {
+try {
+  TableConfig tableConfig = TableConfig.fromZnRecord(znRecord);
+  String tableNameWithType = tableConfig.getTableName();
+  _tableConfigMap.put(tableNameWithType, tableConfig);
+  String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+  //create case insensitive mapping
+  _tableNameMap.put(tableNameWithType.toLowerCase(), 
tableNameWithType);
+  _tableNameMap.put(rawTableName.toLowerCase(), rawTableName);
+  //create case insensitive mapping between table name and 
schemaName
+  _table2SchemaConfigMap.put(tableNameWithType.toLowerCase(), 
rawTableName);
+  _table2SchemaConfigMap.put(rawTableName.toLowerCase(), 
rawTableName);
+} catch (IOException e) {
+  e.printStackTrace();
+  //ignore
+}
+  }
+}
+  } catch (Exception e) {
+e.printStackTrace();
+//ignore
+  }
+}
+
+@Override
+public void handleChildChange(String s, List list)
+throws Exception {
+  refresh();
+}
+
+  

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-14 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r366687957
 
 

 ##
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
 ##
 @@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils.helix;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.apache.helix.AccessOption;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.HelixPropertyListener;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.pinot.common.config.TableConfig;
+import org.apache.pinot.common.config.TableNameBuilder;
+import org.apache.pinot.common.utils.SchemaUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+
+
+public class TableCache {
+  private static final String PROPERTYSTORE_SCHEMAS_PREFIX = "/SCHEMAS";
+  private static final String PROPERTYSTORE_TABLE_CONFIGS_PREFIX = 
"/CONFIGS/TABLE";
+
+  private ZkHelixPropertyStore _propertyStore;
+  TableConfigChangeListener _tableConfigChangeListener;
+  SchemaChangeListener _schemaChangeListener;
+
+  public TableCache(ZkHelixPropertyStore propertyStore) {
+_propertyStore = propertyStore;
+_schemaChangeListener = new SchemaChangeListener();
+_schemaChangeListener.refresh();
+_tableConfigChangeListener = new TableConfigChangeListener();
+_tableConfigChangeListener.refresh();
+  }
+
+  public String getActualTableName(String tableName) {
+return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
+  }
+
+  public String getActualColumnName(String tableName, String columnName) {
+String schemaName = 
_tableConfigChangeListener._table2SchemaConfigMap.get(tableName.toLowerCase());
+if (schemaName != null) {
+  return _schemaChangeListener.getColumnName(schemaName, columnName);
+}
+return columnName;
+  }
+
+  class TableConfigChangeListener implements IZkChildListener, IZkDataListener 
{
+
+Map _tableConfigMap = new ConcurrentHashMap<>();
+Map _tableNameMap = new ConcurrentHashMap<>();
+Map _table2SchemaConfigMap = new ConcurrentHashMap<>();
+
+public synchronized void refresh() {
+  try {
+//always subscribe first before reading, so that we dont miss any 
changes
+
_propertyStore.subscribeChildChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+
_propertyStore.subscribeDataChanges(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
_tableConfigChangeListener);
+List children =
+_propertyStore.getChildren(PROPERTYSTORE_TABLE_CONFIGS_PREFIX, 
null, AccessOption.PERSISTENT);
+if (children != null) {
+  for (ZNRecord znRecord : children) {
+try {
+  TableConfig tableConfig = TableConfig.fromZnRecord(znRecord);
+  String tableNameWithType = tableConfig.getTableName();
+  _tableConfigMap.put(tableNameWithType, tableConfig);
+  String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+  //create case insensitive mapping
+  _tableNameMap.put(tableNameWithType.toLowerCase(), 
tableNameWithType);
+  _tableNameMap.put(rawTableName.toLowerCase(), rawTableName);
+  //create case insensitive mapping between table name and 
schemaName
+  _table2SchemaConfigMap.put(tableNameWithType.toLowerCase(), 
rawTableName);
+  _table2SchemaConfigMap.put(rawTableName.toLowerCase(), 
rawTableName);
+} catch (IOException e) {
+  e.printStackTrace();
+  //ignore
+}
+  }
+}
+  } catch (Exception e) {
+e.printStackTrace();
+//ignore
+  }
+}
+
+@Override
+public void handleChildChange(String s, List list)
+throws Exception {
+  refresh();
+}
+
+  

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4983: Make PQL case insensitive

2020-01-14 Thread GitBox
kishoreg commented on a change in pull request #4983: Make PQL case insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r366687788
 
 

 ##
 File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PqlQueryResource.java
 ##
 @@ -108,6 +108,8 @@ public String getQueryResponse(String pqlQuery, String 
traceEnabled, String quer
 BrokerRequest brokerRequest;
 try {
   brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(pqlQuery);
+  String inputTableName = brokerRequest.getQuerySource().getTableName();
 
 Review comment:
   yes, I realized that as well. Query console is generally used for debugging 
and not worth optimizing it.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org