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_r345030185 ########## 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( Review comment: here better to print duplicate column in error message, you can refer org.apache.carbondata.spark.util.CarbonScalaUtil#validateLocalDictionaryColumns and can change logic like that. ---------------------------------------------------------------- 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 |
Free forum by Nabble | Edit this page |