From issues-return-32822-archive-asf-public=cust-asf.ponee.io@carbondata.apache.org Mon Jan 29 03:37:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 0B9A518064F for ; Mon, 29 Jan 2018 03:37:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EF7C8160C52; Mon, 29 Jan 2018 02:37:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4527A160C43 for ; Mon, 29 Jan 2018 03:37:06 +0100 (CET) Received: (qmail 65749 invoked by uid 500); 29 Jan 2018 02:37:05 -0000 Mailing-List: contact issues-help@carbondata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.apache.org Delivered-To: mailing list issues@carbondata.apache.org Received: (qmail 65740 invoked by uid 99); 29 Jan 2018 02:37:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2018 02:37:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5F1A4E01EC; Mon, 29 Jan 2018 02:37:05 +0000 (UTC) From: xubo245 To: issues@carbondata.apache.org Reply-To: issues@carbondata.apache.org References: In-Reply-To: Subject: [GitHub] carbondata pull request #1865: [CARBONDATA-2088][CARBONDATA-1516] Optimize s... Content-Type: text/plain Message-Id: <20180129023705.5F1A4E01EC@git1-us-west.apache.org> Date: Mon, 29 Jan 2018 02:37:05 +0000 (UTC) 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 ---