Indhumathi27 commented on a change in pull request #4177:
URL: https://github.com/apache/carbondata/pull/4177#discussion_r677643423



##########
File path: 
integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonScanRDD.scala
##########
@@ -566,6 +569,47 @@ class CarbonScanRDD[T: ClassTag](
           }
           havePair = false
           val value = reader.getCurrentValue
+          if (CarbonProperties.getInstance()
+                .getProperty(CarbonCommonConstants.CARBON_SPARK_VERSION_SPARK3,
+                  CarbonCommonConstants.CARBON_SPARK_VERSION_SPARK3_DEFAULT)
+                .toBoolean &&
+              model.getProjectionColumns.exists(_.getDataType == 
DataTypes.TIMESTAMP)) {
+            value match {
+              case row: GenericInternalRow if
+                reader.isInstanceOf[CarbonRecordReader[T]] &&
+                null !=
+                
reader.asInstanceOf[CarbonRecordReader[T]].getCarbonDataFileWrittenVersion &&
+                // carbonDataFileWrittenVersion will be in the format 
x.x.x-SNAPSHOT
+                // (eg., 2.1.0-SNAPSHOT), get the version name and check if 
the data file is
+                // written before 2.2.0 version, then rebase timestamp value
+                
reader.asInstanceOf[CarbonRecordReader[T]].getCarbonDataFileWrittenVersion
+                  .split(CarbonCommonConstants.HYPHEN).head
+                  .compareTo(CarbonCommonConstants.CARBON_SPARK3_VERSION) < 0 
=>
+                var i = 0
+                // rebase timestamp data by converting julian to Gregorian time
+                model.getProjectionColumns.foreach {
+                  projectionColumn =>
+                    var isComplexDimension = false
+                    // ignore Timestamp complex dimensions
+                    projectionColumn match {
+                      case dimension: CarbonDimension =>
+                        isComplexDimension = 
dimension.getComplexParentDimension != null
+                      case _ =>
+                    }
+                    if (!isComplexDimension &&
+                        projectionColumn.getDataType == DataTypes.TIMESTAMP) {
+                      val timeStampData = row.get(i,
+                        org.apache.spark.sql.types.DataTypes.TimestampType)
+                      if (null != timeStampData) {
+                        row.update(i,
+                          
CarbonToSparkAdapter.rebaseTime(timeStampData.asInstanceOf[Long]))
+                      }
+                    }
+                    i = i + 1

Review comment:
       Identified timestamp index from projection column list and updated 
rebase time only for those




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to