-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-39639][SQL] Fix possible null pointer in MySQLDialect listIndexes #37031
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
Conversation
|
seems need this protection, Is it possible to add a UT? |
Updated exist UT: org.apache.spark.sql.jdbc.v2.MySQLIntegrationSuite [info] MySQLIntegrationSuite: |
|
Can one of the admins verify this patch? |
| // The only property we are building here is `COMMENT` because it's the only one | ||
| // we can get from `SHOW INDEXES`. | ||
| val properties = new util.Properties(); | ||
| if (indexComment.nonEmpty) properties.put("COMMENT", indexComment) |
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 to me if Index_comment is not set, MySQL defaults it to empty String?
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.
Yes, you are right! I investigated it carefully.
INDEX_COMMENT nullability is NO, the default value is empty String.
mysql> desc INFORMATION_SCHEMA.STATISTICS;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| TABLE_CATALOG | varchar(512) | NO | | | |
| TABLE_SCHEMA | varchar(64) | NO | | | |
| TABLE_NAME | varchar(64) | NO | | | |
| NON_UNIQUE | bigint(1) | NO | | 0 | |
| INDEX_SCHEMA | varchar(64) | NO | | | |
| INDEX_NAME | varchar(64) | NO | | | |
| SEQ_IN_INDEX | bigint(2) | NO | | 0 | |
| COLUMN_NAME | varchar(64) | NO | | | |
| COLLATION | varchar(1) | YES | | NULL | |
| CARDINALITY | bigint(21) | YES | | NULL | |
| SUB_PART | bigint(3) | YES | | NULL | |
| PACKED | varchar(10) | YES | | NULL | |
| NULLABLE | varchar(3) | NO | | | |
| INDEX_TYPE | varchar(16) | NO | | | |
| COMMENT | varchar(16) | YES | | NULL | |
| INDEX_COMMENT | varchar(1024) | NO | | | |
+---------------+---------------+------+-----+---------+-------+
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.
I will close it, but maybe we need add some UT for it.I will open new pr for it.
FYI: Whether it is necessary to implement createIndex & existIndex & dropIndex & listIndex in H2Dialect ?
I found the above "possible null pointer" when implementing the method: listIndex in H2Dialect(the default value is null instead of empty string). @huaxingao
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.
Updated:
new UT for it: #37060
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.
maybe we need add some UT for it
Sounds good to me. I will take a look at the new PR.
Whether it is necessary to implement createIndex & existIndex & dropIndex & listIndex in H2Dialect ?
It's OK to implement these.
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.
@huaxingao implement for h2 dialect: #37112
|
@panbingkun can you resolve the conflict? |
I will close the PR,reason: |
|
Thank you for closing, @panbingkun . |
What changes were proposed in this pull request?
Fix possible null pointer in MySQLDialect listIndexes
Why are the changes needed?
Code as follow:
https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala#L203~L232
when:
FYI:
then:
finally:
Does this PR introduce any user-facing change?
No
How was this patch tested?
Update exist UT & Pass GA