-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-2817] [SQL] add "show create table" support #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
a03db77
a337bd6
bbf6b42
bb82726
bde800a
bfc2999
9f97586
9b2ba11
dbe1031
60d48a9
565ec14
cbffe8b
7d28b15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,8 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) { | |
| // without restarting the JVM. | ||
| System.clearProperty("spark.hostPort") | ||
|
|
||
|
|
||
|
|
||
| lazy val warehousePath = getTempFilePath("sparkHiveWarehouse").getCanonicalPath | ||
| lazy val metastorePath = getTempFilePath("sparkHiveMetastore").getCanonicalPath | ||
|
|
||
|
|
@@ -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" + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( |
||
| } 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 */ | ||
|
|
@@ -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 { | ||
|
|
||
| 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` |
There was a problem hiding this comment.
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.