Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/518#discussion_r95506643
  
    --- Diff: 
integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
 ---
    @@ -301,4 +304,45 @@ object CommonUtil {
           LOGGER.info(s"mapreduce.input.fileinputformat.split.maxsize: ${ 
newSplitSize.toString }")
         }
       }
    +
    +  def getCsvHeaderColumns(carbonLoadModel: CarbonLoadModel): Array[String] 
= {
    +    val delimiter = if 
(StringUtils.isEmpty(carbonLoadModel.getCsvDelimiter)) {
    +      CarbonCommonConstants.COMMA
    +    } else {
    +      CarbonUtil.delimiterConverter(carbonLoadModel.getCsvDelimiter)
    +    }
    +    var csvFile: String = null
    +    var csvHeader: String = carbonLoadModel.getCsvHeader
    +    val csvColumns = if (StringUtils.isBlank(csvHeader)) {
    +      // read header from csv file
    +      csvFile = carbonLoadModel.getFactFilePath.split(",")(0)
    +      csvHeader = CarbonUtil.readHeader(csvFile)
    +      if (StringUtils.isBlank(csvHeader)) {
    +        throw new CarbonDataLoadingException("First line of the csv is not 
valid.")
    +      }
    +      csvHeader.toLowerCase().split(delimiter).map(_.replaceAll("\"", 
"").trim)
    +    } else {
    +      csvHeader.toLowerCase.split(CarbonCommonConstants.COMMA).map(_.trim)
    +    }
    +
    +    if 
(!CarbonDataProcessorUtil.isHeaderValid(carbonLoadModel.getTableName, 
csvColumns,
    +        carbonLoadModel.getCarbonDataLoadSchema)) {
    +      if (csvFile == null) {
    +        LOGGER.error("CSV header provided in DDL is not proper."
    +                     + " Column names in schema and CSV header are not the 
same.")
    +        throw new CarbonDataLoadingException(
    +          "CSV header provided in DDL is not proper. Column names in 
schema and CSV header are "
    +          + "not the same.")
    +      } else {
    +        LOGGER.error(
    +          "CSV File provided is not proper. Column names in schema and csv 
header are not same. "
    --- End diff --
    
    Better to tell "CSV header in the input file ($csvFile) is not proper."


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

Reply via email to