def detect_oracle_decimal_datatype()

in awswrangler/oracle.py [0:0]


def detect_oracle_decimal_datatype(cursor: Any) -> dict[str, pa.DataType]:
    """Determine if a given Oracle column is a decimal, not just a standard float value."""
    dtype = {}
    _logger.debug("cursor type: %s", type(cursor))
    if isinstance(cursor, oracledb.Cursor):
        # Oracle stores DECIMAL as the NUMBER type

        for name, db_type, display_size, internal_size, precision, scale, null_ok in cursor.description:
            _logger.debug((name, db_type, display_size, internal_size, precision, scale, null_ok))

            if db_type == oracledb.DB_TYPE_NUMBER and scale is not None and scale > 0:
                dtype[name] = pa.decimal128(precision, scale)

    _logger.debug("decimal dtypes: %s", dtype)
    return dtype