Skip to content

Commit

Permalink
[SPARK-47880][SQL][DOCS] Oracle: Document Mapping Spark SQL Data Type…
Browse files Browse the repository at this point in the history
…s to Oracle

### What changes were proposed in this pull request?

Documents Mapping Spark SQL Data Types to Oracle

### Why are the changes needed?

documentation improvement

### Does this PR introduce _any_ user-facing change?
no

### How was this patch tested?

doc build
![image](https://github.com/apache/spark/assets/8326978/3bc7816a-f887-4f8c-95c0-15ec2c4ac7fb)

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#46092 from yaooqinn/SPARK-47880.

Authored-by: Kent Yao <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
  • Loading branch information
yaooqinn committed Apr 17, 2024
1 parent 268856d commit 2054ab0
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions docs/sql-data-sources-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1335,3 +1335,109 @@ as the activated JDBC Driver.
</tr>
</tbody>
</table>

### Mapping Spark SQL Data Types to Oracle

The below table describes the data type conversions from Spark SQL Data Types to Oracle data types,
when creating, altering, or writing data to an Oracle table using the built-in jdbc data source with
the Oracle JDBC as the activated JDBC Driver.

<table>
<thead>
<tr>
<th><b>Spark SQL Data Type</b></th>
<th><b>Oracle Data Type</b></th>
<th><b>Remarks</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>BooleanType</td>
<td>NUMBER(1, 0)</td>
<td>BooleanType maps to NUMBER(1, 0) as BOOLEAN is introduced since Oracle Release 23c</td>
</tr>
<tr>
<td>ByteType</td>
<td>NUMBER(3)</td>
<td></td>
</tr>
<tr>
<td>ShortType</td>
<td>NUMBER(5)</td>
<td></td>
</tr>
<tr>
<td>IntegerType</td>
<td>NUMBER(10)</td>
<td></td>
</tr>
<tr>
<td>LongType</td>
<td>NUMBER(19)</td>
<td></td>
</tr>
<tr>
<td>FloatType</td>
<td>NUMBER(19, 4)</td>
<td></td>
</tr>
<tr>
<td>DoubleType</td>
<td>NUMBER(19, 4)</td>
<td></td>
</tr>
<tr>
<td>DecimalType(p, s)</td>
<td>NUMBER(p,s)</td>
<td></td>
</tr>
<tr>
<td>DateType</td>
<td>DATE</td>
<td></td>
</tr>
<tr>
<td>TimestampType</td>
<td>TIMESTAMP WITH LOCAL TIME ZONE</td>
<td></td>
</tr>
<tr>
<td>TimestampNTZType</td>
<td>TIMESTAMP</td>
<td></td>
</tr>
<tr>
<td>StringType</td>
<td>VARCHAR2(255)</td>
<td>For historical reason, a string value has maximum 255 characters</td>
</tr>
<tr>
<td>BinaryType</td>
<td>BLOB</td>
<td></td>
</tr>
<tr>
<td>CharType(n)</td>
<td>CHAR(n)</td>
<td></td>
</tr>
<tr>
<td>VarcharType(n)</td>
<td>VARCHAR2(n)</td>
<td></td>
</tr>
</tbody>
</table>

The Spark Catalyst data types below are not supported with suitable Oracle types.

- DayTimeIntervalType
- YearMonthIntervalType
- CalendarIntervalType
- ArrayType
- MapType
- StructType
- UserDefinedType
- NullType
- ObjectType
- VariantType

0 comments on commit 2054ab0

Please sign in to comment.