Github user sujith71955 commented on a diff in the pull request: https://github.com/apache/incubator-carbondata/pull/122#discussion_r77332892 --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/util/GlobalDictionaryUtil.scala --- @@ -588,30 +588,59 @@ object GlobalDictionaryUtil extends Logging { allDictionaryPath: String) = { var allDictionaryRdd: RDD[(String, Iterable[String])] = null try { - // read local dictionary file, and spilt (columnIndex, columnValue) - val basicRdd = sqlContext.sparkContext.textFile(allDictionaryPath) - .map(x => { + // parse record and validate record + def parseRecord(x: String, accum: Accumulator[Int]) : (String, String) = { val tokens = x.split("" + CSVWriter.DEFAULT_SEPARATOR) - if (tokens.size != 2) { - logError("Read a bad dictionary record: " + x) - } - var columnName: String = CarbonCommonConstants.DEFAULT_COLUMN_NAME + var columnName: String = "" var value: String = "" - try { - columnName = csvFileColumns(tokens(0).toInt) - value = tokens(1) - } catch { - case ex: Exception => - logError("Reset bad dictionary record as default value") + // such as "," , "", throw ex + if (tokens.size == 0) { + logError("Read a bad dictionary record: " + x) + accum += 1 + } else if (tokens.size == 1) { + // such as "1", "jone", throw ex + if (x.contains(",") == false) { + accum += 1 + } else { + try { + columnName = csvFileColumns(tokens(0).toInt) + } catch { + case ex: Exception => + logError("Read a bad dictionary record: " + x) + accum += 1 + } + } + } else { + try { + columnName = csvFileColumns(tokens(0).toInt) + value = tokens(1) + } catch { + case ex: Exception => + logError("Read a bad dictionary record: " + x) + accum += 1 + } } (columnName, value) - }) + } + val accumulator = sqlContext.sparkContext.accumulator(0) --- End diff -- return the accumulator by updating and let caller validate and throw exception
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---