Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B4383200B4A for ; Wed, 20 Jul 2016 12:13:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B2D82160A73; Wed, 20 Jul 2016 10:13:37 +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 DE340160A64 for ; Wed, 20 Jul 2016 12:13:36 +0200 (CEST) Received: (qmail 8586 invoked by uid 500); 20 Jul 2016 10:13:36 -0000 Mailing-List: contact commits-help@carbondata.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.incubator.apache.org Delivered-To: mailing list commits@carbondata.incubator.apache.org Received: (qmail 8577 invoked by uid 99); 20 Jul 2016 10:13:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2016 10:13:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 954201A01CA for ; Wed, 20 Jul 2016 10:13:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id pTao3005-WCc for ; Wed, 20 Jul 2016 10:13:31 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id F1B3460DBB for ; Wed, 20 Jul 2016 10:13:30 +0000 (UTC) Received: (qmail 7744 invoked by uid 99); 20 Jul 2016 10:13:30 -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; Wed, 20 Jul 2016 10:13:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 20DC5E0C0A; Wed, 20 Jul 2016 10:13:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chenliang613@apache.org To: commits@carbondata.incubator.apache.org Date: Wed, 20 Jul 2016 10:13:54 -0000 Message-Id: <4783edc862244f48b7df27be821c3cad@git.apache.org> In-Reply-To: <5e0daf87cb5643eba1c1b8e77c61f141@git.apache.org> References: <5e0daf87cb5643eba1c1b8e77c61f141@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [26/50] [abbrv] incubator-carbondata git commit: [Bug] Fix query without data load null pointer exception on hdfs (#826) archived-at: Wed, 20 Jul 2016 10:13:37 -0000 [Bug] Fix query without data load null pointer exception on hdfs (#826) fix query without data load null pointer exception * add test cases Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/6b8d35db Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/6b8d35db Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/6b8d35db Branch: refs/heads/master Commit: 6b8d35dba8d4354afe0165d12d442cc27df415c9 Parents: 00ff214 Author: Zhangshunyu Authored: Mon Jul 18 14:39:56 2016 +0800 Committer: Kumar Vishal Committed: Mon Jul 18 12:09:56 2016 +0530 ---------------------------------------------------------------------- .../allqueries/TestQueryWithoutDataLoad.scala | 63 ++++++++++++++++++++ .../lcm/status/SegmentStatusManager.java | 10 +++- 2 files changed, 70 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6b8d35db/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/TestQueryWithoutDataLoad.scala ---------------------------------------------------------------------- diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/TestQueryWithoutDataLoad.scala b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/TestQueryWithoutDataLoad.scala new file mode 100644 index 0000000..b9f9f53 --- /dev/null +++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/TestQueryWithoutDataLoad.scala @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.carbondata.spark.testsuite.allqueries + +import org.apache.spark.sql.Row +import org.apache.spark.sql.common.util.CarbonHiveContext._ +import org.apache.spark.sql.common.util.QueryTest +import org.scalatest.BeforeAndAfterAll + +/* + * Test Class for query without data load + * + */ +class TestQueryWithoutDataLoad extends QueryTest with BeforeAndAfterAll { + override def beforeAll { + sql("drop table if exists no_load") + sql(""" + CREATE TABLE no_load(imei string, age int, productdate timestamp, gamePointId double) + STORED BY 'org.apache.carbondata.format' + TBLPROPERTIES('DICTIONARY_EXCLUDE'='productdate', 'DICTIONARY_INCLUDE'='gamePointId') + """) + } + + test("test query without data load") { + checkAnswer( + sql("select count(*) from no_load"), Seq(Row(0)) + ) + checkAnswer( + sql("select * from no_load"), Seq.empty + ) + checkAnswer( + sql("select imei, count(age) from no_load group by imei"), Seq.empty + ) + checkAnswer( + sql("select imei, sum(age) from no_load group by imei"), Seq.empty + ) + checkAnswer( + sql("select imei, avg(age) from no_load group by imei"), Seq.empty + ) + } + + override def afterAll { + sql("drop table no_load") + } + +} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6b8d35db/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java ---------------------------------------------------------------------- diff --git a/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java b/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java index d5b06f6..e6220d8 100644 --- a/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java +++ b/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java @@ -81,12 +81,16 @@ public class SegmentStatusManager { /** * This method will return last modified time of tablestatus file */ - public long getTableStatusLastModifiedTime() { + public long getTableStatusLastModifiedTime() throws IOException { String tableStatusPath = CarbonStorePath.getCarbonTablePath( absoluteTableIdentifier.getStorePath(), absoluteTableIdentifier.getCarbonTableIdentifier()) .getTableStatusFilePath(); - return FileFactory.getCarbonFile(tableStatusPath, FileFactory.getFileType(tableStatusPath)) - .getLastModifiedTime(); + if (!FileFactory.isFileExist(tableStatusPath, FileFactory.getFileType(tableStatusPath))) { + return 0L; + } else { + return FileFactory.getCarbonFile(tableStatusPath, FileFactory.getFileType(tableStatusPath)) + .getLastModifiedTime(); + } } /**