-
Notifications
You must be signed in to change notification settings - Fork 4
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
Priorities #2
Comments
This looks great. Would you consider doing a BinaryBuilder build for ODPI-C, so that user do not have to compile it themselves? |
Some integration with Tables.jl would be nice. @quinnj might be able to assit. |
Yes, these are all good ideas. |
Yes, Tables.jl integration is something I should have done before, as in with XLSX.jl. |
Yep, happy to help however I can. If someone wants to take a stab at Tables.jl, I'm happy to review, or if you give me some pointers around the code, I could take a stab at doing the integration myself. |
What about support for DECIMAL and NUMERIC types? (up to a point, IEEE decimal floating point formats could be used, using Note: I've found code that describes how to convert to/from Oracle's internal type to a string, that could be used with |
Hi @ScottPJones ! This is something I've been thinking about. Current implementation gets values as Float64, converted from C Oracle documentation describes One possibility I had in mind was to return values as fixed decimals, using FixedPointDecimals.jl. The common use case will be a monetary value, with 2 decimals. I think if I use What do you think about it? |
@felipenoris ping @anthony-tuininga (I can forward email, if that's easier - see my profile) since he has done some work in this area. |
@cjbj , @anthony-tuininga, thanks for the input! |
For Oracle NUMBER, look at https://github.com/oracle/odpi/blob/master/src/dpiData.c#L114 There are pros & cons to doing this on the client side. |
@anthony-tuininga, how does |
@cjbj , @anthony-tuininga, based on this code, whenever I ask a numeric value as bytes, the byte representation is actually a text: Is there a way to get the raw byte representation? Digging in the code, it looks like I have to create a patch to create my own version for Also, maybe a new native type enum value could be defined to ask the driver to get numeric values in a raw representation (maybe a struct with the result of parseOracleNumber). |
Oracle internal number types encode the value so that they can be compared numerically, simply by doing string (byte) comparisons (this is a common technique, that I've used in the past also). The values themselves do not store the precision, that information is only in the metadata you get back from Oracle about the column types. |
You could make a Julia type that directly stores the value (maybe as a 24 or 32 byte bitstype, which would probably be the most compact way of storing the full value in Julia), and then have methods that convert to/from strings (with no loss), or for performing operations, into a |
@ScottPJones Yes! That's exactly the idea! This is very much like the timestamp case, where there's a special struct for it In the case of NUMBER, I could have a struct I'm just not sure if there is a julia type for it. I mean, |
In cx_Oracle and node-oracledb there is no attempt to use the Oracle Number format directly. Instead, it is converted to double, integer or string depending on the needs of the driver. That is because the Oracle Number format is not directly usable and conversion to/from that format is not simple. If you really want to deal with it yourself directly I could add a "native type" which simply passes the value through to you directly. If that is the case, please add an enhancement request to ODPI-C for that purpose. |
The reason a fixed size might be better, is that using something like
|
That would be great to have in ODPI-C, IMO. |
@anthony-tuininga , nice!!! Let me study oracle's format, then I'll open an issue with detailed information. |
@ScottPJones , I see. So there is a tradeoff between memory consumption and performance here. |
Actually, both memory consumption and performance are better, if you can use a fixed size immutable or bitstype. |
Think of a vector of these things, the vector itself might be n * pointer size, but then you will need around 64 bytes for each element in the vector (and will be doing indirections through the pointers every time you access one of them). |
@ScottPJones , I see. But say I have an immutable parametric type like So, a vector of values of type I might be wrong in my understanding. You're much more experienced in this area! :) |
You could probably define an 8, 16, and 24 byte sizes, depending on whether the column is declared with just NUMBER (or DECIMAL), in which case it would need the larger size to support arbitrary Oracle numbers, |
Note: if we did want the (hardware supported on IBM platforms, nice since Julia runs on the LE Power), I could restart my attempt to get the |
No, if
Precisely, you'd simply need to look at the precision value that Oracle gives you, to see which type to use for that particular column. |
Oh, I just thought of another thing. Maybe this numeric support should not be put into this package, but rather, a package that can be used with ODBC.jl, and another other database wrapper that needs to correctly support database DECIMAL and NUMERIC types. |
@ScottPJones I think we agree on the concepts. I just need to study a bit more to choose a solution. About DECIMAL/NUMERIC, does Oracle DB has them? I mean, this page lists |
Ah, I see where I got confused: Oracle OLAP DML has |
Here is a good description of the ANSI SQL numeric types: |
@anthony-tuininga, I'm making progress getting the internal representation of OCINumber (https://github.com/felipenoris/odpi/tree/fn/numeric). But for math operations on OCINumbers, maybe I should use the functions already implemented in OCI. What I tried to do was to load Should this be the way to go (call libclntsh functions directly), or for this to work these functions must be wrapped in odpi? I'm confused if I should setup an environment to create an error handle before calling OCINumberAdd. For now I'm just passing a null pointer for the error handle, and maybe that's the reason I'm getting an error code as the result of the function OCINumberAdd. |
I'd been looking at Let me know if you feel this might be useful for dealing with the Oracle numbers in Julia. |
For now I'm trying to use OCI directly, which has a set of math functions defined for OCINumber data type. As far as I can tell, all operations are done using full 22 byte representation. I just tried to add a new public method to odpi, but all I'm getting are segfaults... :( // [PUBLIC]
int dpiNumber_add(const dpiNumber *number1, const dpiNumber *number2, dpiNumber *result)
{
dpiError error;
return dpiOci__numberAdd(&error, number1, number2, result);
} |
I'll investigate those functions, but I can't debug anything, I don't have any Oracle database to test with. |
Ref oracle/odpi#100 |
@ScottPJones I've been taking a look at your code. I could read native On this subject, I would have a few questions for you:
|
Yes, it supports an arbitrary number of digits, up to the memory of the machine, and an exponent that is an Int32 (whereas Oracle has a single byte UInt8 exponent, offset so that it is 10^-130 to 10^125 instead of 10^-128 to 10^127)
As far as the math functions, it would directly support at unlimited precision
I wasn't aware of If it's easy to interface and fast, I'd probably move |
@JeffreySarnoff, I was wondering if you have any opinions on how to go about supporting oracle numbers as fixed decimals (not floating point). This could be the first driver to have this feature AFAIK. I'm able to read and write them from the database in Oracle's native format, but I currently do not support the math around it, as I was discussing with Scott in this thread. |
give me a working definition of an oracle number -- or a reference please (the discussion is unclear) |
@JeffreySarnoff , thanks for the fast reply! The best definition I found was this one from Oracle docs:
The Julia struct for that is this: const MAX_SIZEOF_MANTISSA = 20
struct OraNumber <: Real
len::UInt8
ex::UInt8
mantissa::NTuple{MAX_SIZEOF_MANTISSA, UInt8}
end I sketched a few functions to handle it in https://github.com/felipenoris/Oracle.jl/tree/master/src/oranumbers. |
... when you define a column as |
Oh, so is your question: "given an |
Is it OK to convert the |
Exactly! Few options arised: Decs.jl, libmpdec, Decimals.jl, or implement support for Yes, it is ok to convert to an |
are you looking to support these math functions? (once you have the numbers, what do you need to do with them?) |
@JeffreySarnoff well, the basic idea is that I want |
... but keep in mind that it might be |
|
https://github.com/JuliaMath/DecFP.jl exports |
@JeffreySarnoff Thanks! I'll check out if I can convert back and forth directly, without intermediate string representation. |
|
addRef
DateTime
!
from API methods.ROWID
data typeexecute_many
helper method that operates directly on a statementBase.show
methods for data structuresThe text was updated successfully, but these errors were encountered: