Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ class HiveCompatibilitySuite extends HiveQueryFileTest with BeforeAndAfter {
"serde_regex",
"serde_reported_schema",
"set_variable_sub",
"show_create_table_partitioned",
"show_create_table_delimited",
"show_create_table_alter",
"show_create_table_view",
"show_create_table_serde",
"show_create_table_db_table",
"show_create_table_does_not_exist",
"show_create_table_index",
"show_describe_func_quotes",
"show_functions",
"show_partitions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private[hive] object HiveQl {
protected val nativeCommands = Seq(
"TOK_DESCFUNCTION",
"TOK_DESCDATABASE",
"TOK_SHOW_CREATETABLE",
"TOK_SHOW_TABLESTATUS",
"TOK_SHOWDATABASES",
"TOK_SHOWFUNCTIONS",
Expand Down
14 changes: 14 additions & 0 deletions sql/hive/src/main/scala/org/apache/spark/sql/hive/TestHive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
// without restarting the JVM.
System.clearProperty("spark.hostPort")



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove these spurious new line additions? Below as well.

lazy val warehousePath = getTempFilePath("sparkHiveWarehouse").getCanonicalPath
lazy val metastorePath = getTempFilePath("sparkHiveMetastore").getCanonicalPath

Expand All @@ -70,6 +72,17 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
set("hive.metastore.warehouse.dir", warehousePath)
}

val testTmpDir = if (System.getProperty("user.dir").endsWith("sql" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be:

val testTempDir = File.createtempfile("", "spark.hive.tmp")
testTempDir.delete()
testTempDir.mkdir()

I'm not sure why we would want to keep temporary files in the source tree instead of the system temporary folder.

File.separator + "hive")) {
new File(System.getProperty("user.dir") + File.separator + "tmp")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All we need is the temporal folder, not sure why we have to check the user working directory if end with sql/hive,
Can we just use val testTmpDir = new File(System.getProperty("user.dir") + File.separator + "tmp") instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenghao-intel I did not understand why we have to check that too. I just follow the same way of handling "inRepoTests"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in repo tests is checking to see if the tests are there or if we should look for them in the hive distribution (they weren't always bundled with the source tree). If we need a temporary directory, we should use the mechanisms provided by the JVM for that (File.createTempFile)

} else {
new File(System.getProperty("user.dir") + File.separator + "sql" +
File.separator + "hive" + File.separator + "tmp")
}

// For some hive test case which contain ${system:test.tmp.dir}
System.setProperty("test.tmp.dir", testTmpDir.getCanonicalPath)

configure() // Must be called before initializing the catalog below.

/** The location of the compiled hive distribution */
Expand Down Expand Up @@ -109,6 +122,7 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
hiveFilesTemp.mkdir()
hiveFilesTemp.deleteOnExit()


val inRepoTests = if (System.getProperty("user.dir").endsWith("sql" + File.separator + "hive")) {
new File("src" + File.separator + "test" + File.separator + "resources" + File.separator)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key smallint,
value float)
CLUSTERED BY (
key)
SORTED BY (
value DESC)
INTO 5 BUCKETS
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132100')
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE tmp_showcrt1(
key smallint,
value float)
COMMENT 'temporary table'
CLUSTERED BY (
key)
SORTED BY (
value DESC)
INTO 5 BUCKETS
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'EXTERNAL'='FALSE',
'last_modified_by'='tianyi',
'last_modified_time'='1407132100',
'transient_lastDdlTime'='1407132100')
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key smallint,
value float)
COMMENT 'changed comment'
CLUSTERED BY (
key)
SORTED BY (
value DESC)
INTO 5 BUCKETS
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'last_modified_by'='tianyi',
'last_modified_time'='1407132100',
'transient_lastDdlTime'='1407132100')
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key smallint,
value float)
COMMENT 'changed comment'
CLUSTERED BY (
key)
SORTED BY (
value DESC)
INTO 5 BUCKETS
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'last_modified_by'='tianyi',
'last_modified_time'='1407132101',
'transient_lastDdlTime'='1407132101')
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key smallint,
value float)
COMMENT 'changed comment'
CLUSTERED BY (
key)
SORTED BY (
value DESC)
INTO 5 BUCKETS
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED BY
'org.apache.hadoop.hive.ql.metadata.DefaultStorageHandler'
WITH SERDEPROPERTIES (
'serialization.format'='1')
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'last_modified_by'='tianyi',
'last_modified_time'='1407132101',
'transient_lastDdlTime'='1407132101')
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
default
tmp_feng
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE tmp_feng.tmp_showcrt(
key string,
value int)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_feng.db/tmp_showcrt'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132107')
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE tmp_showcrt1(
key int,
value string,
newvalue bigint)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION ITEMS TERMINATED BY '|'
MAP KEYS TERMINATED BY '%'
LINES TERMINATED BY '\n'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/tmp_showcrt1'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132730')
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key string,
newvalue boolean COMMENT 'a new value')
COMMENT 'temporary table'
PARTITIONED BY (
value bigint COMMENT 'some value')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132112')
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE tmp_showcrt1(
key int,
value string,
newvalue bigint)
COMMENT 'temporary table'
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.RCFileInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.RCFileOutputFormat'
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132115')
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE EXTERNAL TABLE tmp_showcrt1(
key string,
value boolean)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe'
STORED BY
'org.apache.hadoop.hive.ql.metadata.DefaultStorageHandler'
WITH SERDEPROPERTIES (
'serialization.format'='$',
'field.delim'=',')
LOCATION
'file:/tmp/sparkHiveWarehouse1280221975983654134/tmp_showcrt1'
TBLPROPERTIES (
'transient_lastDdlTime'='1407132115')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE VIEW tmp_copy_src AS SELECT `src`.`key`, `src`.`value` FROM `default`.`src`
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ abstract class HiveComparisonTest
"transient_lastDdlTime",
"grantTime",
"lastUpdateTime",
"last_modified_by",
"last_modified_time",
"Owner:",
// The following are hive specific schema parameters which we do not need to match exactly.
Expand Down