carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xubo245 <...@git.apache.org>
Subject [GitHub] carbondata pull request #1865: [CARBONDATA-2088][CARBONDATA-1516] Optimize s...
Date Mon, 29 Jan 2018 02:37:05 GMT
Github user xubo245 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1865#discussion_r164326340
  
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/timeseries/TimeSeriesUtil.scala
---
    @@ -54,6 +56,107 @@ object TimeSeriesUtil {
         }
       }
     
    +  def getGranularityKey(dmProperties: Map[String, String]): String = {
    +
    +    if (dmProperties.get(YEAR.getName).isDefined) {
    +      return YEAR.getName
    +    }
    +    if (dmProperties.get(MONTH.getName).isDefined) {
    +      return MONTH.getName
    +    }
    +    if (dmProperties.get(DAY.getName).isDefined) {
    +      return DAY.getName
    +    }
    +    if (dmProperties.get(HOUR.getName).isDefined) {
    +      return HOUR.getName
    +    }
    +    if (dmProperties.get(MINUTE.getName).isDefined) {
    +      return MINUTE.getName
    +    }
    +    if (dmProperties.get(SECOND.getName).isDefined) {
    +      return SECOND.getName
    +    }
    +    throw new CarbonIllegalArgumentException(
    +      s"${TIMESERIES.getName} should define time granularity")
    +  }
    +  def validateTimeSeriesGranularity(
    +      dmProperties: Map[String, String],
    +      dmClassName: String): Boolean = {
    +    var sum = 0
    +
    +    if (dmProperties.get(YEAR.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +    if (dmProperties.get(MONTH.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +    if (dmProperties.get(DAY.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +    if (dmProperties.get(HOUR.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +    if (dmProperties.get(MINUTE.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +    if (dmProperties.get(SECOND.getName).isDefined) {
    +      sum = sum + 1
    +    }
    +
    +    val granularity = if (sum > 1 || sum < 0) {
    +      throw new UnsupportedDataMapException(
    +        s"Granularity only support one")
    +    } else if (sum == 1) {
    +      true
    +    } else {
    +      false
    +    }
    +
    +    if (granularity && !dmClassName.equalsIgnoreCase(TIMESERIES.getName)) {
    +      throw new CarbonIllegalArgumentException(
    +        s"It should using ${TIMESERIES.getName}")
    --- End diff --
    
    ok, done


---

Mime
View raw message