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

Cannot create LIST partition on data type other than INT #1

Open
iShiBin opened this issue May 12, 2017 · 2 comments
Open

Cannot create LIST partition on data type other than INT #1

iShiBin opened this issue May 12, 2017 · 2 comments

Comments

@iShiBin
Copy link

iShiBin commented May 12, 2017

Hi @michaljuhas

I am now doing 'S04-P01-Practice'. However, I got error when I want to create a LIST partition. Here is my code and the error message. Could you please help?

CREATE TABLE `sample_staff`.`invoice_partitioned` AS SELECT * FROM `sample_staff`.`invoice`;
ALTER TABLE invoice_partitioned ADD COLUMN department_code VARCHAR(35); 
ALTER TABLE `sample_staff`.`invoice_partitioned`  REMOVE PARTITIONING ;

UPDATE invoice_partitioned,
    department_employee_rel,
    department 
SET 
    invoice_partitioned.department_code = department.code
WHERE
    invoice_partitioned.employee_id = department_employee_rel.employee_id
        AND department_employee_rel.department_id = department.id
        AND invoice_partitioned.invoiced_date BETWEEN department_employee_rel.from_date AND department_employee_rel.to_date
;

ALTER TABLE invoice_partitioned
partition BY LIST(department_code) (
partition CS	values in ("CS"),
partition	DEV	values in ("DEV"),
partition	FIN	values in ("FIN"),
partition	HR	values in ("HR"),
partition	MKT	values in ("MKT"),
partition	PROD	values in ("PROD"),
partition	QA	values in ("QA"),
partition	RES	values in ("RES"),
partition	SAL	values in ("SAL")
)
;

Error message: Error Code: 1697. VALUES value for partition 'CS' must have type INT

@iShiBin
Copy link
Author

iShiBin commented May 12, 2017

I even add the partition for the null value, but it does not work.

ALTER TABLE invoice_partitioned
partition BY LIST(department_code) (
partition CS	values in ('CS'),
partition DEV	values in ('DEV'),
partition	FIN	values in ('FIN'),
partition	HR	values in ('HR'),
partition	MKT	values in ('MKT'),
partition	PROD	values in ('PROD'),
partition	QA	values in ('QA'),
partition	RES	values in ('RES'),
partition	SAL	values in ('SAL'),
PARTITION NUL values in (null)
)
;

@iShiBin
Copy link
Author

iShiBin commented May 12, 2017

I think it should work but unfortunately it has not worked. So instead, I add another INT column to make it work.

ALTER TABLE invoice_partitioned ADD COLUMN department_id INT;

UPDATE invoice_partitioned,
    department_employee_rel 
SET 
    invoice_partitioned.department_id = department_employee_rel.department_id
WHERE
    invoice_partitioned.employee_id = department_employee_rel.employee_id
        AND invoice_partitioned.invoiced_date BETWEEN department_employee_rel.from_date AND department_employee_rel.to_date
;

ALTER TABLE invoice_partitioned
partition BY LIST(department_id) (
partition	CS	values in (	1	),
partition	DEV	values in (	2	),
partition	FIN	values in (	3	),
partition	HR	values in (	4	),
partition	MKT	values in (	5	),
partition	PROD	values in (	6	),
partition	QA	values in (	7	),
partition	RES	values in (	8	),
partition	SAL	values in (	9	),
partition NUL values in (null)
)
;

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

No branches or pull requests

1 participant