[GitHub] [carbondata] akashrn5 commented on a change in pull request #3436: [WIP]Geospatial Support: Modified to create and load table with invisible dimension sort column

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akashrn5 commented on a change in pull request #3436: [WIP]Geospatial Support: Modified to create and load table with invisible dimension sort column

GitBox
akashrn5 commented on a change in pull request #3436: [WIP]Geospatial Support: Modified to create and load table with invisible dimension sort column
URL: https://github.com/apache/carbondata/pull/3436#discussion_r345027548
 
 

 ##########
 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(",")
 
 Review comment:
   wherever using split(","), better trim also, it will handle the extra space also, so that column matching won't fail

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


With regards,
Apache Git Services