Skip to content
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

Add supports to Insert Into #9

Merged
merged 7 commits into from
Feb 10, 2018

Conversation

weiqingy
Copy link
Contributor

@weiqingy weiqingy commented Feb 8, 2018

Changes:
Merge code supporting "Insert Into" and "Create View xx As Select * From xx" into master branch.

Testing:
New unit tests were added.
I manually tested this PR in HDP cluster:
Case1:
sql("create table table_parquet_200 (a int) using parquet")
sql("insert into table table_parquet_200 values (200)")
sql("create table table_parquet_300 (a int) using parquet")
sql("INSERT INTO table_parquet_300 SELECT * FROM table_parquet_200")

Case2:
sql("CREATE TABLE t00000(a int)")
sql("INSERT INTO t00000 VALUES (1)")
sql("CREATE TABLE t10000(a int)")
sql("INSERT INTO t10000 SELECT * FROM t00000")

Case 3:
sql("CREATE TABLE sourceTable(a int)")
sql("INSERT INTO sourceTable VALUES (1)")
sql("CREATE view s_view1 as select * from sourceTable")

@weiqingy
Copy link
Contributor Author

weiqingy commented Feb 8, 2018

cc: @dongjoon-hyun

May I add unit tests in another PR?

@weiqingy
Copy link
Contributor Author

weiqingy commented Feb 8, 2018

I'll add the unit tests in this PR soon

@weiqingy weiqingy force-pushed the InsertInto branch 2 times, most recently from 83c6cbd to e96d7ff Compare February 9, 2018 04:37
@weiqingy
Copy link
Contributor Author

weiqingy commented Feb 9, 2018

Hi @dongjoon-hyun , I have added the unit tests.

cc: @jerryshao

super.beforeAll()
sparkSession = SparkSession.builder()
.master("local")
.config("spark.sql.catalogImplementation", "hive")
Copy link
Contributor

Choose a reason for hiding this comment

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

.config("spark.sql.catalogImplementation", "hive") ==> enableHiveSupport()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

override def beforeAll(): Unit = {
super.beforeAll()
sparkSession = SparkSession.builder()
.master("local")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, local[1]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both local and local[1] will run Spark locally with one worker thread

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see.

sparkSession.sql(s"CREATE TABLE $sourceHiveTblName (name string)")
sparkSession.sql(s"INSERT INTO TABLE $sourceHiveTblName VALUES ('a'), ('b'), ('c')")

sparkSession.sql(s"CREATE TABLE $sourceSparkTblName (name string) USING PARQUET")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use USING ORC instead of USING ORC? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Done.

@dongjoon-hyun
Copy link
Contributor

Thank you for merging and adding UTs.
Can we proceed this after adding Travis CI, #12 ?

@dongjoon-hyun
Copy link
Contributor

Next time when you update some code in this PR, Travis CI will be triggered.

@weiqingy
Copy link
Contributor Author

weiqingy commented Feb 9, 2018

Thanks, @dongjoon-hyun . I'll update this PR soon.

case c: CreateDataSourceTableAsSelectCommand =>
logDebug(s"CREATE TABLE USING xx AS SELECT query: ${qd.qe}")
CommandsHarvester.CreateDataSourceTableAsSelectHarvester.harvest(c, qd)

case c: CreateViewCommand =>
Copy link
Contributor

@dongjoon-hyun dongjoon-hyun Feb 10, 2018

Choose a reason for hiding this comment

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

Do we have a test case for this? Otherwise, can we add this in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, not yet. I'll add unit tests for CreateViewCommand

@dongjoon-hyun
Copy link
Contributor

@weiqingy . Please update PR description because you added the test case and Travis CI verified that. Overall, LGTM. I think we can proceed to another PRs.

cc @jerryshao

@weiqingy
Copy link
Contributor Author

Thanks @dongjoon-hyun . The unit test for CreateViewHarvester was added.

@weiqingy weiqingy merged commit ca6cda9 into hortonworks-spark:master Feb 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants