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

[SPARK-19004][SQL] Fix JDBCWriteSuite.testH2Dialect by removing getCatalystType #16409

Closed
wants to merge 1 commit into from
Closed

[SPARK-19004][SQL] Fix JDBCWriteSuite.testH2Dialect by removing getCatalystType #16409

wants to merge 1 commit into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Dec 26, 2016

What changes were proposed in this pull request?

JDBCSuite and JDBCWriterSuite have their own testH2Dialects for their testing purposes.

This PR fixes testH2Dialect in JDBCWriterSuite by removing getCatalystType implementation in order to return correct types. Currently, it always returns Some(StringType) incorrectly. Note that, for the testH2Dialect in JDBCSuite, it's intentional because of the test case Remap types via JdbcDialects.

How was this patch tested?

This is a test only update.

@dongjoon-hyun
Copy link
Member Author

Hi, @gatorsmile .
Could you review this PR?

@SparkQA
Copy link

SparkQA commented Dec 26, 2016

Test build #70612 has finished for PR 16409 at commit fe8f827.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@@ -44,9 +44,6 @@ class JDBCWriteSuite extends SharedSQLContext with BeforeAndAfter {

val testH2Dialect = new JdbcDialect {
override def canHandle(url: String) : Boolean = url.startsWith("jdbc:h2")
override def getCatalystType(
Copy link
Member

Choose a reason for hiding this comment

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

If we get rid of this, how can it pass the test case "Remap types via JdbcDialects". At least, it failed in my local environement.

This overwrite was intentionally introduced for testing JdbcDialect. See the PR: #5498

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for review, @gatorsmile .

JdbcDialect should handle a few DBMS specific types and should return None for general types. The schema is handled in general in the following fallback logic.

https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala#L245-L246

The current implementation is wrong because it returns always StringType for all kind types of columns.

Copy link
Member

Choose a reason for hiding this comment

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

I know that is wrong, but this customized getCatalystType is used to test whether the customized getCatalystType are taking effects.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check that again for test.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the failure, I see that it's due to complaining the correct result.

List(StructField(THEID,IntegerType,false)) was not empty
ScalaTestFailureLocation: org.apache.spark.sql.jdbc.JDBCSuite$$anonfun$39 at (JDBCSuite.scala:616)

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Dec 27, 2016

Choose a reason for hiding this comment

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

First of all, it's my bad that I didn't notice that there were two testH2Dialect.

Now, I understand that this is intentional for the specific test case Remap types via JdbcDialects, but it seems to be only valid for JDBCSuite.scala.

I mean we can use a normal JdbcDialect in JDBCWriteSuite because it's a different suite. Actually, while making #15664, I got stuck by this bug.
Is it possible to fix this correctly in JDBCWriterSuite only as this PR proposed?

Copy link
Member

Choose a reason for hiding this comment

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

uh, I see. you are removing testH2Dialect in JDBCWriteSuite.scala. I am fine about this change. Please update the PR title, and the PR/JIRA description.

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Dec 27, 2016

Choose a reason for hiding this comment

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

Thank you so much, @gatorsmile .
I update the title and description of this PR and JIRA together.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-19004][SQL] Fix testH2Dialect by removing getCatalystType [SPARK-19004][SQL] Fix JDBCWriteSuite.testH2Dialect by removing getCatalystType Dec 27, 2016
@gatorsmile
Copy link
Member

Thanks! Merging to master.

@asfgit asfgit closed this in c2a2069 Dec 27, 2016
@dongjoon-hyun
Copy link
Member Author

Thank you for review and merging!

cmonkey pushed a commit to cmonkey/spark that referenced this pull request Dec 29, 2016
…tCatalystType`

## What changes were proposed in this pull request?

`JDBCSuite` and `JDBCWriterSuite` have their own `testH2Dialect`s for their testing purposes.

This PR fixes `testH2Dialect` in `JDBCWriterSuite` by removing `getCatalystType` implementation in order to return correct types. Currently, it always returns `Some(StringType)` incorrectly. Note that, for the `testH2Dialect` in `JDBCSuite`, it's intentional because of the test case `Remap types via JdbcDialects`.

## How was this patch tested?

This is a test only update.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes apache#16409 from dongjoon-hyun/SPARK-H2-DIALECT.
@dongjoon-hyun dongjoon-hyun deleted the SPARK-H2-DIALECT branch December 29, 2016 20:55
uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
…tCatalystType`

## What changes were proposed in this pull request?

`JDBCSuite` and `JDBCWriterSuite` have their own `testH2Dialect`s for their testing purposes.

This PR fixes `testH2Dialect` in `JDBCWriterSuite` by removing `getCatalystType` implementation in order to return correct types. Currently, it always returns `Some(StringType)` incorrectly. Note that, for the `testH2Dialect` in `JDBCSuite`, it's intentional because of the test case `Remap types via JdbcDialects`.

## How was this patch tested?

This is a test only update.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes apache#16409 from dongjoon-hyun/SPARK-H2-DIALECT.
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.

3 participants