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

Oracle BLOB throws exceptions for column and row validation #991

Closed
nj1973 opened this issue Sep 14, 2023 · 4 comments · Fixed by #1005
Closed

Oracle BLOB throws exceptions for column and row validation #991

nj1973 opened this issue Sep 14, 2023 · 4 comments · Fixed by #1005
Assignees
Labels
priority: p2 Medium priority. Fix may not be included in next release (e.g. minor documentation, cleanup) type: feature request 'Nice-to-have' improvement, new feature or different behavior or design.

Comments

@nj1973
Copy link
Contributor

nj1973 commented Sep 14, 2023

This has been requested by a large bank so is something we should try to prioritise.

Test Oracle table:

create table dvt_test.tab_blob (id number(6), col_blob blob, col_raw raw(64));
insert into dvt_test.tab_blob values (1,empty_blob(),NULL);
insert into dvt_test.tab_blob values (2,utl_raw.cast_to_raw('some binary data'),utl_raw.cast_to_raw('some binary data'));
insert into dvt_test.tab_blob values (3,NULL,NULL);
commit;

Test PostgreSQL table:

create table dvt_test.tab_blob (id decimal(6), col_blob bytea, col_raw bytea);
insert into dvt_test.tab_blob values (1,null,null);
insert into dvt_test.tab_blob values (2,'some binary data'::bytea,'some binary data'::bytea);
insert into dvt_test.tab_blob values (3,null,null);

Column validation

Counts:

data-validation -v validate column -sc=ora_local -tc=pg_local -tbls=dvt_test.tab_blob --count=col_blob,col_raw

sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-00932: inconsistent datatypes: expected - got BLOB
[SQL: SELECT count(*) AS count, count(t0.col_blob) AS count__col_blob
FROM dvt_test.tab_blob t0]

Sum/min/max:

data-validation -v validate column -sc=ora_local -tc=pg_local -tbls=dvt_test.tab_blob --min=col_blob,col_raw

# No error but the column is skipped

data-validation -v validate column -sc=ora_local -tc=pg_local -tbls=dvt_test.tab_blob --sum=col_blob,col_raw

# No error but the column is skipped

Row validation

Oracle to Oracle validation:

data-validation -v validate row -sc=ora_local -tc=ora_local -tbls=dvt_test.tab_blob \
--primary-keys=id --hash=col_blob

(SELECT t6.id AS id, t6.col_blob AS col_blob, encode(t6.col_blob, :encode_1) AS cast__col_blob
FROM dvt_test.tab_blob AS t6),
t1 AS
...
    cursor.execute(statement, parameters)
cx_Oracle.DatabaseError: ORA-00904: "ENCODE": invalid identifier

PostgreSQL to PostgreSQL is fine:

data-validation -v validate row -sc=pg_local -tc=pg_local -tbls=dvt_test.tab_blob \
--primary-keys=id --hash=col_blob

# success

Once #899 is complete we should add a BLOB column to the new test table.

@nj1973 nj1973 added type: feature request 'Nice-to-have' improvement, new feature or different behavior or design. priority: p2 Medium priority. Fix may not be included in next release (e.g. minor documentation, cleanup) labels Sep 14, 2023
@nj1973 nj1973 self-assigned this Sep 14, 2023
@nj1973
Copy link
Contributor Author

nj1973 commented Sep 14, 2023

I thought I'd found a custom-query row validation workaround for BLOB validation but we are blocked by #992

@nj1973
Copy link
Contributor Author

nj1973 commented Sep 14, 2023

For count validation we could enclose the BLOB column in an expression like this which takes care of empty_blob().

nullif(dbms_lob.getlength(col_blob),0)

But this is not trivial because both BLOB and RAW show up as the binary Ibis type. Therefore we need to be able to look at the Oracle type.

@nj1973
Copy link
Contributor Author

nj1973 commented Sep 14, 2023

For min/max/sum we could research using the length like we do for strings. That would work for Oracle and PostgreSQL at least, we would need to check on all engines.

@nj1973
Copy link
Contributor Author

nj1973 commented Sep 27, 2023

I propose to leave row validation out of this issue because it is already logged: #773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Medium priority. Fix may not be included in next release (e.g. minor documentation, cleanup) type: feature request 'Nice-to-have' improvement, new feature or different behavior or design.
Projects
None yet
1 participant