Provide Struct data type support for oracle plugin - #659
Provide Struct data type support for oracle plugin#659vanshikaagupta22 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for resolving Oracle STRUCT types into CDAP RECORD schemas by querying the ALL_TYPE_ATTRS metadata table. The implementation includes recursive resolution for nested structures and an updated mapping for primitive Oracle types. Feedback highlights several critical issues: the metadata query lacks an OWNER filter which could lead to incorrect schema resolution in multi-schema environments; fully qualified type names containing dots will cause IllegalArgumentException when creating CDAP records; and there are logic errors in the primitive type mapping, specifically regarding Oracle-specific type naming conventions and an invalid comparison between Java class names and SQL type strings.
a88c6b7 to
231c6ee
Compare
e6834e3 to
fe03c7b
Compare
# Conflicts: # oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java # oracle-plugin/src/test/java/io/cdap/plugin/oracle/OracleSchemaReaderTest.java
a11f5cc to
af67d36
Compare
af67d36 to
3bfd8ba
Compare
f4ab512 to
47834bb
Compare
47834bb to
219b85e
Compare
| recordBuilder.set(field.getName(), bigDecimal.longValue()); | ||
| break; | ||
| case STRING: | ||
| recordBuilder.set(field.getName(), bigDecimal.toString()); |
3455570 to
7495c92
Compare
| Object[] attributes = struct.getAttributes(); | ||
| if (attributes != null) { | ||
| try { | ||
| Object descriptor = struct.getClass().getMethod("getDescriptor").invoke(struct); |
There was a problem hiding this comment.
We use reflection to extract column names via getDescriptor() without adding a compile-time dependency on ojdbc (which is provided at runtime).
7495c92 to
046c0be
Compare
046c0be to
d24127c
Compare
This change adds native support for resolving Oracle STRUCT types (Object Types) into CDAP RECORD schemas. By querying the ALL_TYPE_ATTRS metadata table, the schema builder dynamically processes complex structures with support for up to 4 levels of nesting. Internal attributes are first translated to standard SQL data types via a dedicated mapper before being converted into the final CDAP schema.
When reading the data, the implementation overrides the setField() function, providing a custom implementation to properly extract and map individual custom object attributes according to requirements.
Note: Users will require explicit EXECUTE privileges on the custom Oracle object types to successfully resolve the schema.