[GitHub] carbondata pull request #842: [CARBONDATA-937] Data loading for partition ta...

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

[GitHub] carbondata pull request #842: [CARBONDATA-937] Data loading for partition ta...

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

    https://github.com/apache/carbondata/pull/842#discussion_r116006191
 
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -931,6 +954,82 @@ object CarbonDataRDDFactory {
     
       }
     
    +  /**
    +   * repartition the input data for partiton table.
    +   * @param sqlContext
    +   * @param dataFrame
    +   * @param carbonLoadModel
    +   * @return
    +   */
    +  private def repartitionInputData(sqlContext: SQLContext,
    +      dataFrame: Option[DataFrame],
    +      carbonLoadModel: CarbonLoadModel): RDD[Row] = {
    +    val carbonTable = carbonLoadModel.getCarbonDataLoadSchema.getCarbonTable
    +    val partitionInfo = carbonTable.getPartitionInfo(carbonTable.getFactTableName)
    +    val partitionColumn = partitionInfo.getColumnSchemaList.get(0).getColumnName
    +    val partitionColumnDataType = partitionInfo.getColumnSchemaList.get(0).getDataType
    +    val columns = carbonLoadModel.getCsvHeaderColumns
    +    var partitionColumnIndex = -1
    +    for (i <- 0 until columns.length) {
    +      if (partitionColumn.equals(columns(i))) {
    +        partitionColumnIndex = i
    +      }
    +    }
    +    if (partitionColumnIndex == -1) {
    +      throw new DataLoadingException("Partition column not found.")
    +    }
    +    // generate RDD[(K, V)] to use the partitionBy method of PairRDDFunctions
    +    val inputRDD: RDD[(String, Row)] = if (dataFrame.isDefined) {
    +      // input data from DataFrame
    +      val timestampFormatString = CarbonProperties.getInstance().getProperty(CarbonCommonConstants
    +        .CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT)
    +      val timeStampFormat = new SimpleDateFormat(timestampFormatString)
    +      val dateFormatString = CarbonProperties.getInstance().getProperty(CarbonCommonConstants
    +        .CARBON_DATE_FORMAT, CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT)
    +      val dateFormat = new SimpleDateFormat(dateFormatString)
    +      val delimiterLevel1 = carbonLoadModel.getComplexDelimiterLevel1
    +      val delimiterLevel2 = carbonLoadModel.getComplexDelimiterLevel2
    +      val serializationNullFormat =
    +        carbonLoadModel.getSerializationNullFormat.split(CarbonCommonConstants.COMMA, 2)(1)
    +      dataFrame.get.rdd.map { row =>
    +        (CarbonScalaUtil.getString(row.get(partitionColumnIndex), serializationNullFormat,
    +          delimiterLevel1, delimiterLevel2, timeStampFormat, dateFormat), row)
    +      }
    +    } else {
    +      // input data from files
    --- End diff --
   
    mention CSV files, not all files are supported


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---