VenuReddy2103 commented on a change in pull request #3436: 
[CARBONDATA-3548]Geospatial Support: Modified to create and load the table with 
a nonschema dimension sort column. And added InPolygon UDF
URL: https://github.com/apache/carbondata/pull/3436#discussion_r349879032
 
 

 ##########
 File path: 
integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
 ##########
 @@ -268,6 +309,151 @@ abstract class CarbonDDLSqlParser extends 
AbstractCarbonSparkSQLParser {
     }
   }
 
+  /**
+   * The method parses, validates and processes the index_handler property.
+   *
+   * @param tableProperties Table properties
+   * @param tableFields     Sequence of table fields
+   * @return <Seq[Field]> Sequence of table fields
+   *
+   */
+  private def processIndexProperty(tableProperties: mutable.Map[String, 
String],
+                                   tableFields: Seq[Field]): Seq[Field] = {
+    val option = tableProperties.get(CarbonCommonConstants.INDEX_HANDLER)
+    val fields = ListBuffer[Field]()
+    if (option.isDefined) {
+      if (option.get.isEmpty) {
+        throw new MalformedCarbonCommandException(
+          s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is invalid. 
" +
+            s"Option value is empty.")
+      }
+
+      val handlers = option.get.split(",")
+      handlers.foreach { e =>
+        /* Validate target column name */
+        if (tableFields.exists(_.column.equalsIgnoreCase(e))) {
+          throw new MalformedCarbonCommandException(
+            s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is 
invalid. " +
+              s"handler value : $e is not allowed. It matches with another 
column name in table. " +
+              s"Cannot create column with it.")
+        }
+
+        val sourceColumnsOption = tableProperties.get(
+          CarbonCommonConstants.INDEX_HANDLER + s".$e.sourcecolumns")
+        if (sourceColumnsOption.isEmpty) {
+          throw new MalformedCarbonCommandException(
+            s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is 
invalid. " +
+              s"${CarbonCommonConstants.INDEX_HANDLER}.$e.sourcecolumns 
property is not specified.")
+        } else if (sourceColumnsOption.get.isEmpty) {
+          throw new MalformedCarbonCommandException(
+            s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is 
invalid. " +
+              s"${CarbonCommonConstants.INDEX_HANDLER}.$e.sourcecolumns 
property cannot be empty.")
+        }
+
+        /* Validate source columns */
+        val sources = sourceColumnsOption.get.split(",")
+        if (sources.distinct.length != sources.size) {
+          throw new MalformedCarbonCommandException(
+            s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is 
invalid. " +
+              s"${CarbonCommonConstants.INDEX_HANDLER}.$e.sourcecolumns 
property " +
+              s"have duplicate columns.")
+        }
+
+        val sourceTypes = StringBuilder.newBuilder
+        sources.foreach { column =>
+          tableFields.find(_.column.equalsIgnoreCase(column)) match {
+            case Some(field) => 
sourceTypes.append(field.dataType.get).append(",")
+            case None =>
+              throw new MalformedCarbonCommandException(
+                s"Carbon ${CarbonCommonConstants.INDEX_HANDLER} property is 
invalid. " +
+                  s"Source column : $column in property " +
 
 Review comment:
   Modified.

----------------------------------------------------------------
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

Reply via email to