Skip to content

Commit 2f1bea0

Browse files
committed
fix hive test case
1 parent 5ba93de commit 2f1bea0

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

integration/hive/pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@
3636
</properties>
3737

3838
<dependencies>
39+
<dependency>
40+
<artifactId>hadoop-yarn-registry</artifactId>
41+
<groupId>org.apache.hadoop</groupId>
42+
<version>${hadoop.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.apache.hadoop</groupId>
46+
<artifactId>hadoop-yarn-server-resourcemanager</artifactId>
47+
<version>${hadoop.version}</version>
48+
<exclusions>
49+
<exclusion>
50+
<groupId>javax.servlet</groupId>
51+
<artifactId>servlet-api</artifactId>
52+
</exclusion>
53+
<exclusion>
54+
<groupId>org.slf4j</groupId>
55+
<artifactId>slf4j-log4j12</artifactId>
56+
</exclusion>
57+
</exclusions>
58+
</dependency>
3959
<dependency>
4060
<groupId>org.apache.hive</groupId>
4161
<artifactId>hive-exec</artifactId>
@@ -61,6 +81,10 @@
6181
<artifactId>kryo</artifactId>
6282
<groupId>com.esotericsoftware.kryo</groupId>
6383
</exclusion>
84+
<exclusion>
85+
<artifactId>hadoop-yarn-registry</artifactId>
86+
<groupId>org.apache.hadoop</groupId>
87+
</exclusion>
6488
</exclusions>
6589
<scope>compile</scope>
6690
</dependency>
@@ -109,6 +133,12 @@
109133
<artifactId>tez-dag</artifactId>
110134
<version>0.9.1</version>
111135
<scope>test</scope>
136+
<exclusions>
137+
<exclusion>
138+
<artifactId>hadoop-yarn-client</artifactId>
139+
<groupId>org.apache.hadoop</groupId>
140+
</exclusion>
141+
</exclusions>
112142
</dependency>
113143
<dependency>
114144
<groupId>org.apache.spark</groupId>

integration/hive/src/main/java/org/apache/carbondata/hive/test/server/HiveEmbeddedServer2.java

+6-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.apache.hadoop.hive.conf.HiveConf;
3333
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
3434
import org.apache.hadoop.hive.ql.metadata.Hive;
35-
import org.apache.hadoop.hive.ql.session.SessionState;
3635
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
3736
import org.apache.hive.service.Service;
3837
import org.apache.hive.service.cli.CLIService;
@@ -47,15 +46,15 @@
4746
* a child JVM (which Hive calls local) or external.
4847
*/
4948
public class HiveEmbeddedServer2 {
50-
private String SCRATCH_DIR = "";
49+
private String STORE_DIR = "";
5150
private static final Logger log = LogServiceFactory.getLogService(Hive.class.getName());
5251
private HiveServer2 hiveServer;
5352
private HiveConf config;
5453
private int port;
5554

5655
public void start(String storePath) throws Exception {
5756
log.info("Starting Hive Local/Embedded Server...");
58-
SCRATCH_DIR = storePath;
57+
STORE_DIR = storePath;
5958
if (hiveServer == null) {
6059
System.setProperty("datanucleus.schema.autoCreateAll", "true");
6160
System.setProperty("hive.metastore.schema.verification", "false");
@@ -114,20 +113,17 @@ private CLIService getServiceClientInternal() {
114113

115114
private HiveConf configure() throws Exception {
116115
log.info("Setting The Hive Conf Variables");
117-
String scratchDir = SCRATCH_DIR;
118-
119116
Configuration cfg = new Configuration();
120117
HiveConf conf = new HiveConf(cfg, HiveConf.class);
121118
conf.addToRestrictList("columns.comments");
122119
conf.set("hive.scratch.dir.permission", "777");
123120
conf.setVar(ConfVars.SCRATCHDIRPERMISSION, "777");
124-
125-
conf.set("hive.metastore.warehouse.dir", scratchDir + "/warehouse");
126-
conf.set("hive.metastore.metadb.dir", scratchDir + "/metastore_db");
127-
conf.set("hive.exec.scratchdir", scratchDir);
121+
conf.set("hive.metastore.warehouse.dir", STORE_DIR + "/warehouse");
122+
conf.set("hive.metastore.metadb.dir", STORE_DIR + "/metastore_db");
123+
conf.set("hive.exec.scratchdir", STORE_DIR + "/scratch");
128124
conf.set("fs.permissions.umask-mode", "000");
129125
conf.set("javax.jdo.option.ConnectionURL",
130-
"jdbc:derby:;databaseName=" + scratchDir + "/metastore_db" + ";create=true");
126+
"jdbc:derby:;databaseName=" + STORE_DIR + "/metastore_db" + ";create=true");
131127
conf.set("hive.metastore.local", "true");
132128
conf.set("hive.aux.jars.path", "");
133129
conf.set("hive.added.jars.path", "");
@@ -146,9 +142,6 @@ private HiveConf configure() throws Exception {
146142
props.remove("mapreduce.framework.name");
147143
props.setProperty("fs.default.name", "file:///");
148144

149-
// intercept SessionState to clean the threadlocal
150-
Field tss = SessionState.class.getDeclaredField("tss");
151-
tss.setAccessible(true);
152145
return conf;
153146
}
154147

integration/hive/src/test/java/org/apache/carbondata/hive/HiveCarbonTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void verifyLocalDictionaryValues() throws Exception {
8383
statement.execute("CREATE TABLE hive_carbon_table(shortField SMALLINT , intField INT, bigintField BIGINT , doubleField DOUBLE, stringField STRING, timestampField TIMESTAMP, decimalField DECIMAL(18,2), dateField DATE, charField CHAR(5), floatField FLOAT) stored by 'org.apache.carbondata.hive.CarbonStorageHandler' TBLPROPERTIES ('local_dictionary_enable'='true','local_dictionary_include'='stringField')");
8484
statement.execute("insert into hive_carbon_table select * from hive_table");
8585
File rootPath = new File(HiveTestUtils.class.getResource("/").getPath() + "../../../..");
86-
String storePath = rootPath.getAbsolutePath() + "/integration/hive/target/warehouse/warehouse/hive_carbon_table/";
86+
String storePath = rootPath.getAbsolutePath() + "/integration/hive/target/warehouse/hive_carbon_table/";
8787
ArrayList<DimensionRawColumnChunk> dimRawChunk = CarbonTestUtil.getDimRawChunk(storePath, 0);
8888
String[] dictionaryData = new String[]{"hive", "impala", "flink", "spark"};
8989
assert(CarbonTestUtil.validateDictionary(dimRawChunk.get(0), dictionaryData));

integration/hive/src/test/java/org/apache/carbondata/hive/HiveTestUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public HiveTestUtils() {
4545
static {
4646
try {
4747
File rootPath = new File(HiveTestUtils.class.getResource("/").getPath() + "../../../..");
48-
String targetLoc = rootPath.getAbsolutePath() + "/integration/hive/target/warehouse";
49-
String metadatadbLoc = rootPath.getAbsolutePath() + "/integration/hive/target/metastore_db";
48+
String targetLoc = rootPath.getCanonicalPath() + "/integration/hive/target";
49+
String metadatadbLoc = targetLoc + "/metastore_db";
5050
File file = new File(metadatadbLoc);
5151
if (file.exists()) {
5252
file.delete();

0 commit comments

Comments
 (0)