yugabyte / yb-voyager

Data migration Engine for YugabyteDB database
38 stars 10 forks source link

[ORACLE] Incorrect DDLs built for schemas involving multiple sub-partitions #590

Open chetank-yb opened 2 years ago

chetank-yb commented 2 years ago

Jira Link: DB-13476 Description: MINVALUE is not passed to a sub-partition.

Schema used

DROP TABLE DONATIONS;
CREATE TABLE donations
( id             NUMBER
, name           VARCHAR2(60)
, beneficiary    VARCHAR2(80)
, payment_method VARCHAR2(30)
, currency       VARCHAR2(3)
, amount         NUMBER
) PARTITION BY LIST (currency)
SUBPARTITION BY RANGE (amount)
( PARTITION p_eur VALUES ('eur')
  ( SUBPARTITION p_eur_medium VALUES LESS THAN (350)
  , SUBPARTITION p_eur_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_gbp VALUES ('gbp')
  ( SUBPARTITION p_gbp_medium VALUES LESS THAN (300)
  , SUBPARTITION p_gbp_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_aud_nzd_chf VALUES ('aud','nzd','chf')
  ( SUBPARTITION p_aud_nzd_chf_medium VALUES LESS THAN (250)
  , SUBPARTITION p_aud_nzd_chf_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_jpy VALUES ('jpy')
  ( SUBPARTITION p_jpy_medium VALUES LESS THAN (260)
  , SUBPARTITION p_jpy_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_inr VALUES ('inr')
  ( SUBPARTITION p_inr_medium VALUES LESS THAN (200)
  , SUBPARTITION p_inr_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_zar VALUES ('zar')
  ( SUBPARTITION p_zar_medium VALUES LESS THAN (240)
  , SUBPARTITION p_zar_high VALUES LESS THAN (MAXVALUE)
  )
, PARTITION p_default VALUES (DEFAULT)
  ( SUBPARTITION p_default_medium VALUES LESS THAN (340)
  , SUBPARTITION p_default_high VALUES LESS THAN (MAXVALUE)
  )
) ENABLE ROW MOVEMENT;

Data used

DECLARE
    name VARCHAR2(60);
    beneficiary VARCHAR2(80);
    amount NUMBER;
    TYPE PAYMENTMETHODARR IS VARRAY(5) OF VARCHAR2(30);
    TYPE CURRENCYARR IS VARRAY(7) OF VARCHAR2(3);
    PAY PAYMENTMETHODARR;
    CUR CURRENCYARR;
BEGIN
    PAY := PAYMENTMETHODARR('CREDIT CARD', 'DEBIT CARD', 'UPI', 'LATER', 'LOAN');
    CUR := CURRENCYARR('zar','inr','aud','jpy','gbp','eur','def');
    FOR i in 1..5000 
    LOOP
        select DBMS_RANDOM.STRING('A', DBMS_RANDOM.VALUE(4,10)) INTO name FROM DUAL; 
        select DBMS_RANDOM.STRING('C', DBMS_RANDOM.VALUE(4,10)) INTO beneficiary FROM DUAL; 
        select round(dbms_random.value(1,400)) INTO amount from dual;
        Insert into donations values (i, name, beneficiary,PAY(dbms_random.value(1,5)), CUR(dbms_random.value(1,7)), amount); 
        If mod(i, 5000) = 0 then 
        Commit; 
        End if; 
    END LOOP; 
END;
/

yb-voyager logs

2022-11-15 08:49:51 INFO importData.go:1035 Execute SQL file "/home/ubuntu/export-dir/schema/partitions/partition.sql" on target "10.9.203.12"
2022-11-15 08:49:51 INFO analyzeSchema.go:577 Reading PARTITION in dir /home/ubuntu/export-dir/schema/partitions/partition.sql
2022-11-15 08:49:51 INFO importData.go:1090 On 10.9.203.12 run query:
CREATE TABLE donations_p_eur PARTITION OF donations
FOR VALUES IN ('eur')
PARTITION BY RANGE (amount);

2022-11-15 08:49:51 INFO importData.go:1090 On 10.9.203.12 run query:
CREATE TABLE donations_p_eur_p_eur_medium PARTITION OF donations_p_eur
FOR VALUES FROM (MINVALUE) TO (350);

2022-11-15 08:49:52 INFO importData.go:1090 On 10.9.203.12 run query:
CREATE TABLE donations_p_eur_high PARTITION OF donations DEFAULT;

2022-11-15 08:49:52 INFO importData.go:1090 On 10.9.203.12 run query:
CREATE TABLE donations_p_gbp PARTITION OF donations
FOR VALUES IN ('gbp')
PARTITION BY RANGE (amount);

2022-11-15 08:49:53 INFO importData.go:1090 On 10.9.203.12 run query:
CREATE TABLE donations_p_gbp_p_gbp_medium PARTITION OF donations_p_gbp
FOR VALUES FROM () TO (300);
sanyamsinghal commented 2 years ago

hi @chetank-yb i also got the same issue on trying. I think we will have to raise the issue with ora2pg. Btw what should be the right FROM value for partition donations_p_gbp_p_gbp_medium