MOBIN-F commented on issue #3308:
URL: https://github.com/apache/paimon/issues/3308#issuecomment-2103801534
I reproduced the problem, and the reason is as stated in the official
documentation: If you do not have a PRIMARY KEY and an application asks for the
PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no
NULL columns as the PRIMARY KEY.
CREATE TABLE `test_implicit_pk` (
`id` bigint(20) NOT null,
`name` varchar(255) NOT NULL,
`school` varchar(50) DEFAULT NULL,
UNIQUE key uk_sta_id (`id`,name),
UNIQUE KEY `uk_sta` (`school`)
) ENGINE=InnoDB
>desc test_implicit_pk
```
Field |Type |Null|Key|Default|Extra|
------+------------+----+---+-------+-----+
id |bigint(20) |NO |PRI| | |
name |varchar(255)|NO |PRI| | |
school|varchar(50) |YES |UNI| | |
actual primary key information exists
```
>show create table test_implicit_pk
```
CREATE TABLE `test_implicit_pk` (
`id` bigint(20) NOT NULL,
`name` varchar(255) NOT NULL,
`school` varchar(50) DEFAULT NULL,
UNIQUE KEY `uk_sta_id` (`id`,`name`),
UNIQUE KEY `uk_sta` (`school`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
No primary key information is displayed
```
In this case, the primary key information cannot be obtained using
metaData.getPrimaryKeys. Instead, we need to use metaData.getIndexInfo and
metaData.getColumns to determine the primary key
what do you think? @JingsongLi @yuzelin
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]