You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/06/12 18:35:00 UTC
[09/24] git commit: DRILL-537: Add a unittest that reads from a Hive
table which has all supported data types in Hive->Drill.
DRILL-537: Add a unittest that reads from a Hive table which has all supported data types in Hive->Drill.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/9f3b9d29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/9f3b9d29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/9f3b9d29
Branch: refs/heads/master
Commit: 9f3b9d298d68bc6cfc1aae512a0d1addc27810b6
Parents: 72084e3
Author: vkorukanti <ve...@gmail.com>
Authored: Tue Jun 10 16:09:08 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed Jun 11 16:07:07 2014 -0700
----------------------------------------------------------------------
.../exec/store/hive/HiveTestDataGenerator.java | 39 ++++++++++++++------
.../apache/drill/jdbc/test/TestJdbcQuery.java | 1 +
.../apache/drill/jdbc/test/TestMetadataDDL.java | 2 +
3 files changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9f3b9d29/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
index 5a511c0..6aa68b4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
@@ -88,6 +88,13 @@ public class HiveTestDataGenerator {
// create a table with no data
executeQuery("CREATE TABLE IF NOT EXISTS default.empty_table(a INT, b STRING)");
+ // create a table that has all supported types in Drill
+ testDataFile = generateAllTypesDataFile();
+ executeQuery("CREATE TABLE IF NOT EXISTS alltypes (c1 INT, c2 BOOLEAN, c3 DOUBLE, c4 STRING, " +
+ "c9 TINYINT, c10 SMALLINT, c11 FLOAT, c12 BIGINT, c19 BINARY) " +
+ "ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE");
+ executeQuery(String.format("LOAD DATA LOCAL INPATH '%s' OVERWRITE INTO TABLE default.alltypes", testDataFile));
+
ss.close();
}
@@ -98,7 +105,7 @@ public class HiveTestDataGenerator {
executeQuery(String.format("LOAD DATA LOCAL INPATH '%s' OVERWRITE INTO TABLE %s.%s", dataFile, dbName, tblName));
}
- private String generateTestDataFile() throws Exception {
+ private File getTempFile() throws Exception {
File file = null;
while (true) {
file = File.createTempFile("drill-hive-test", ".txt");
@@ -111,6 +118,12 @@ public class HiveTestDataGenerator {
logger.debug("retry creating tmp file");
}
+ return file;
+ }
+
+ private String generateTestDataFile() throws Exception {
+ File file = getTempFile();
+
PrintWriter printWriter = new PrintWriter(file);
for (int i=1; i<=5; i++)
printWriter.println (String.format("%d, key_%d", i, i));
@@ -120,17 +133,7 @@ public class HiveTestDataGenerator {
}
private String generateTestDataFileWithDate() throws Exception {
- File file = null;
- while (true) {
- file = File.createTempFile("drill-hive-test-date", ".txt");
- if (file.exists()) {
- boolean success = file.delete();
- if (success) {
- break;
- }
- }
- logger.debug("retry creating tmp file");
- }
+ File file = getTempFile();
PrintWriter printWriter = new PrintWriter(file);
for (int i=1; i<=5; i++) {
@@ -143,6 +146,18 @@ public class HiveTestDataGenerator {
return file.getPath();
}
+ private String generateAllTypesDataFile() throws Exception {
+ File file = getTempFile();
+
+ PrintWriter printWriter = new PrintWriter(file);
+ printWriter.println("\\N,\\N,\\N,\\N,\\N,\\N,\\N,\\N,\\N");
+ printWriter.println("-1,false,-1.1,,-1,-1,-1.0,-1,\\N");
+ printWriter.println("1,true,1.1,1,1,1,1.0,1,YWJjZA==");
+ printWriter.close();
+
+ return file.getPath();
+ }
+
private void executeQuery(String query) {
CommandProcessorResponse response = null;
boolean failed = false;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9f3b9d29/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index 2a69469..bf4e12e 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -80,6 +80,7 @@ public class TestJdbcQuery extends JdbcTest{
public void testHiveReadWithDb() throws Exception{
testQuery("select * from hive.`default`.kv");
testQuery("select key from hive.`default`.kv group by key");
+ testQuery("select * from hive.`default`.alltypes");
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9f3b9d29/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
index 5299bb5..3975ead 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
@@ -50,6 +50,7 @@ public class TestMetadataDDL extends TestJdbcQuery {
.sql("SHOW TABLES")
.returns(
"TABLE_SCHEMA=hive.default; TABLE_NAME=empty_table\n" +
+ "TABLE_SCHEMA=hive.default; TABLE_NAME=alltypes\n" +
"TABLE_SCHEMA=hive.default; TABLE_NAME=kv\n" +
"TABLE_SCHEMA=hive.default; TABLE_NAME=foodate\n"
);
@@ -71,6 +72,7 @@ public class TestMetadataDDL extends TestJdbcQuery {
.sql("SHOW TABLES IN hive.`default`")
.returns(
"TABLE_SCHEMA=hive.default; TABLE_NAME=empty_table\n" +
+ "TABLE_SCHEMA=hive.default; TABLE_NAME=alltypes\n" +
"TABLE_SCHEMA=hive.default; TABLE_NAME=kv\n" +
"TABLE_SCHEMA=hive.default; TABLE_NAME=foodate\n");
}