-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[SPARK-31467][SQL][TEST] Refactor the sql tests to prevent TableAlreadyExistsException #28239
Conversation
test
in hive/SQLQuerySuite
Just add withTempView for the tests that do not clean up used tables/views. |
test
in hive/SQLQuerySuite
ok to test |
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
I think (trivial though), the change looks ok. Did you check them only in |
Test build #121460 has finished for PR 28239 at commit
|
Hi, I found this issue when adding UT into hive/SQLQuerySuite. I just check the sql/SQLQuerySuite and refactor it too. |
Test build #121467 has finished for PR 28239 at commit
|
Will try to refactor other suites. |
I have used cc @maropu |
Test build #121466 has finished for PR 28239 at commit
|
Test build #121468 has finished for PR 28239 at commit
|
Test build #121470 has finished for PR 28239 at commit
|
retest this please |
I think |
Oh, I mean that if we createOrReplaceTempView and does not clean up it after this test. |
Ur, I see. cc: @dongjoon-hyun |
|AS (c STRING, d STRING) | ||
|ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' | ||
|WITH SERDEPROPERTIES('field.delim' = '|') | ||
withTempView("data") { |
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.
data
-> test
?
""" | ||
|select complexArrayOfStruct[0].field1[1].inner2[0], | ||
|complexArrayOfStruct[1].field2[0][1] | ||
|from jsonTable | ||
""".stripMargin), |
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.
nit: wrong indents.
thanks, will fix all indents related with |
Test build #121473 has finished for PR 28239 at commit
|
Have refactor the indents and double check it. |
Test build #121477 has finished for PR 28239 at commit
|
btw, since I think we tend to forget the cleanup, any other solution to automatically clean up temp views with low overheads after each test, if this issue's annoying? |
It is difficult to identify which view should be cleaned up. spark/sql/core/src/test/scala/org/apache/spark/sql/sources/TableScanSuite.scala Lines 139 to 151 in 88d39e5
This temp view is created in |
Ah, I see. |
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.
Seems fine to me.
retest this please |
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.
LGTM, too.
Test build #122295 has finished for PR 28239 at commit
|
…dyExistsException ### What changes were proposed in this pull request? If we add UT in hive/SQLQuerySuite or other sql test suites and use table named `test`. We may meet TableAlreadyExistsException. ``` org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException: Table or view 'test' already exists in database 'default' ``` The reason is that, there is some tests that does not clean up the tables/views. In this PR, I add `withTempViews` for these tests. ### Why are the changes needed? To fix the TableAlreadyExistsException issue when adding an UT, which uses table named `test` or others, in some sql test suites, such as hive/SQLQuerySuite. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Existed UT. Closes #28239 from turboFei/SPARK-31467. Authored-by: turbofei <fwang12@ebay.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org> (cherry picked from commit 8d1f7d2) Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
Thanks! Merged to master/3.0. |
What changes were proposed in this pull request?
If we add UT in hive/SQLQuerySuite or other sql test suites and use table named
test
.We may meet TableAlreadyExistsException.
The reason is that, there is some tests that does not clean up the tables/views.
In this PR, I add
withTempViews
for these tests.Why are the changes needed?
To fix the TableAlreadyExistsException issue when adding an UT, which uses table named
test
or others, in some sql test suites, such as hive/SQLQuerySuite.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existed UT.