Login  Register

[GitHub] [carbondata] ShreelekhyaG commented on a change in pull request #4118: [CARBONDATA-4167][CARBONDATA-4168] Fix case sensitive issues and input validation for Geo values.

Posted by GitBox on Apr 26, 2021; 8:05am
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-ShreelekhyaG-opened-a-new-pull-request-4118-WIP-Fix-case-sensitive-issues-and-inpu-tp107430p107876.html


ShreelekhyaG commented on a change in pull request #4118:
URL: https://github.com/apache/carbondata/pull/4118#discussion_r620062903



##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParserUtil.scala
##########
@@ -564,7 +564,7 @@ object CarbonSparkSqlParserUtil {
   def needToConvertToLowerCase(key: String): Boolean = {
     var noConvertList = Array(CarbonCommonConstants.COMPRESSOR, "PATH", "bad_record_path",
       "timestampformat", "dateformat")
-    if (key.startsWith(CarbonCommonConstants.SPATIAL_INDEX) && key.endsWith(".class")) {
+    if (key.toLowerCase.startsWith(CarbonCommonConstants.SPATIAL_INDEX) && key.endsWith(".class")) {

Review comment:
       Done. edited existing test cases.

##########
File path: geo/src/main/java/org/apache/carbondata/geo/GeoHashIndex.java
##########
@@ -136,17 +139,21 @@ public void init(String indexName, Map<String, String> properties) throws Except
     }
     String GRID_SIZE = commonKey + "gridsize";
     String gridSize = properties.get(GRID_SIZE);
-    if (StringUtils.isEmpty(gridSize)) {
+    if (StringUtils.isEmpty(gridSize) ||
+        !Pattern.compile(POSITIVE_INTEGER_REGEX).matcher(gridSize).find()) {
       throw new MalformedCarbonCommandException(
-              String.format("%s property is invalid. %s property must be specified.",
-                      CarbonCommonConstants.SPATIAL_INDEX, GRID_SIZE));
+          String.format("%s property is invalid. %s property must be specified, "
+                  + "and the value must be positive integer.",
+              CarbonCommonConstants.SPATIAL_INDEX, GRID_SIZE));
     }
     String CONVERSION_RATIO = commonKey + "conversionratio";
     String conversionRatio = properties.get(CONVERSION_RATIO);
-    if (StringUtils.isEmpty(conversionRatio)) {
+    if (StringUtils.isEmpty(conversionRatio) ||

Review comment:
       Done

##########
File path: geo/src/main/java/org/apache/carbondata/geo/GeoHashUtils.java
##########
@@ -83,6 +85,17 @@ public static long lonLat2GeoID(long longitude, long latitude, double oriLatitud
     return colRow2GeoID(ij[0], ij[1]);
   }
 
+  public static void validateUDFInputValue(Object input, String inputName, String datatype)
+      throws MalformedCarbonCommandException {
+    if (inputName.equalsIgnoreCase("gridSize") && (input == null
+        || Integer.parseInt(input.toString()) <= 0)) {

Review comment:
       Done

##########
File path: geo/src/main/java/org/apache/carbondata/geo/scan/expression/PolygonRangeListExpression.java
##########
@@ -49,14 +49,18 @@ public PolygonRangeListExpression(String polygonRangeList, String opType, String
   public void processExpression() {
     // 1. parse the range list string
     List<String> rangeLists = new ArrayList<>();
-    Pattern pattern = Pattern.compile(GeoConstants.RANGELIST_REG_EXPRESSION);
+    Pattern pattern =
+        Pattern.compile(GeoConstants.RANGELIST_REG_EXPRESSION, Pattern.CASE_INSENSITIVE);
     Matcher matcher = pattern.matcher(polygon);
     while (matcher.find()) {
       String matchedStr = matcher.group();
       rangeLists.add(matchedStr);
     }
     // 2. process the range lists
     if (rangeLists.size() > 0) {
+      if (!opType.equals("OR") && !opType.equals("AND")) {

Review comment:
       done




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