History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SQL-32
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bob Swift
Reporter: Bharathi Vedurumudi
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Confluence SQL Plugin

SQL Macro need to handle array data type

Created: 17/Apr/08 07:05 AM   Updated: 26/Apr/08 12:16 AM
Component/s: SQL macro
Affects Version/s: 3.3.0
Fix Version/s: 3.4.0

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive mylyn-context.zip (2 kb)
2. Java Archive File sql-plugin-3.4.0-b3.jar (113 kb)
3. Java Archive File sql-plugin-3.4.0-b4.jar (113 kb)

Environment: Confluence Version: 2.6.0 Build:#913 Sep 27, 2007 on Tomcat 5.0.25 + beta_fix SQL macro 3.3.1b1

Labels:


 Description  « Hide
Hi ,
I have some new requirement for this SQL macro. If you can provide me some suggestion on implementation , i would like to work on it.
The requirement is that suppose a select sql has a column which is of Array type, example float[] , then the output should display all the values for this array as separate rows. also if there is a column in the select sql which is not an array type , the value of this column should be repeated on each row of the array.
Please let me know if it is not clear. I wrote some java code to do it but i would like to customize the SQL Marco so that, i can make better use of confluence, otherwise I might have to think of different options to develop an application which is more data orientanted -doesnot have much business requirement.
Thanks so much for your help
Bharathi

 All   Comments   Work Log   Change History   FishEye   Crucible   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Bharathi Vedurumudi - 18/Apr/08 08:54 AM - edited
Hi Bob,
Could you please help me with this issue? I really need this functionality. Could you please help me to modify this plugin code?
I could not find the latest source code after 3.3.0. I see the beta version as jars but no source code.

Help !

Thanks
Bharathi


Bob Swift - 18/Apr/08 10:49 AM
Bharathi, I am just about ready (this weekend perhaps) to release the next version. I believe if you agree with my suggestion about handling array types, that it could be included. I think it is only a few lines of code. I do not agree with your original suggestion due to the likely complexity it may introduce - unless you can convince we its not. I still don't know how you propose to handle the case of multiple array fields.

Bharathi Vedurumudi - 18/Apr/08 11:20 AM
Bob,
Thanks so much for your reply. I agree that my proposal might introduce some complexity. I would like to go ahead with your suggestion of handling arraytypes.

Thank you once again
Bharathi


Bob Swift - 21/Apr/08 08:13 AM
Initial beta. Please verify this satisfies your request. A few regression tests aren't quite right and need to be investigated. This does not support macro-security without a non-released plugin. Hopefully, this will all get finished soon.

Bharathi Vedurumudi - 21/Apr/08 11:58 AM
Hi Bob.
Thank you so much for such a quick build. I will test it and let you know if I find any issues.

Regards
Bharathi


Quent Chalmers - 21/Apr/08 05:36 PM
Bob,
How should this work? The following are the query and result displayed: {sql:dataSource=PhsDev|multipleResults=false|output=html}
select measured_depth from survey where unique_identifier = '174000000' {sql}

Result was one row in table format:
measured_depth
[F@db177d

From a beanshell the following results in table of measured_depths:
...
Statement select = connection.createStatement();
ResultSet result = select.executeQuery(
"select measured_depth " +
"from survey " +
"where unique_identifier = '174000000' ");

while (result.next())
{
Object mdObject = result.getObject(1);
float[] mdFloatArray = (float [])mdObject;

int arrayLength = mdFloatArray.length;

out.println("measured_depth array length = " + arrayLength);

for (int index = 0; index < arrayLength; index++)

{ out.println("measured_depth[" + index +"]=" + mdFloatArray[index]); }

...

Results:
measured_depth array length = 131
measured_depth0=0.0
measured_depth1=1884.0
measured_depth2=1985.0
measured_depth3=2298.0
.
.
.


Bob Swift - 21/Apr/08 11:12 PM - edited
What database are you using? I should have investigated differences in how databases handle array types. If it is not consistent between databases its going to be a real pain. I tested only with postgresql.

Bharathi, did you do any investigation on this.

Also, forgot to mention earlier, a new parameter will be needed to turn on this type of processing instead of the current behavior. This is NOT implemented in b3 but will be needed for general release to retain upward compatibility with existing behavior.


Bharathi Vedurumudi - 21/Apr/08 11:30 PM
Bob,
This morning I was having trouble setting up the Datasource for standalone confluence in my local PC. Actually , I work with Quentin and we tried to deploy the new plugin in one of our linux servers. The result is as described by Quentin.

We are using a proprietary JDBC driver to a middle tier server. driver class is com.phs.client.jdbc.PhsJDBCDriver.

I will work on this more tomorrow.

Thanks
Bharathi



Bharathi Vedurumudi - 22/Apr/08 06:50 AM
Bob,
Could you please tell me what new parameter i should use for displaying array type?
Thanks
Bharathi

Bharathi Vedurumudi - 22/Apr/08 10:15 AM
Bob,
We tried to use this modified plugin for Oracle instance. It looks good.
I would like to make modifications to this so that it works for PowerHub datasources also. Could you please help me with that?
Thanks
Bharathi

Bob Swift - 22/Apr/08 05:41 PM
Bharathi, array processing on always on with b3 (see my edited note above). Glad it work with a standard database driver. Regarding PowerHub, I don't know what that is. It sounds like it is a non-standard jdbc driver. Regarding, help, my priorities are to get the next version out and do not have much time for non-standard support.

Bharathi Vedurumudi - 22/Apr/08 05:56 PM
Bob,

Thanks for the help. I would like to know if the new version that is going to be released with have this array processing or not. We are thinking of using Oracle database directly instead of using PowerHub middle tier server so it will be really help to have this new functionality in the next version.
Thanks for your time .

I really appreciate.
Bharathi


Bob Swift - 22/Apr/08 06:39 PM
Yes, that is the plan. And you help to verify it works correctly will help that. I will try to put out a final beta tonight and if that checks out, I will release it soon.

Bob Swift - 22/Apr/08 11:04 PM
Adds parameter expandArray defaults to false. Set to true to expand arrays.

Bharathi Vedurumudi - 23/Apr/08 07:15 AM
Bob, I checked out the new version , do you think if the expandArray is defaulted to false , the value should be treated as string and display the array as string instead of null in the colunm? I think it should be displayed as string. I am seeing the data as below where COL1 is of array type, i think this might be misleading.

COL2 COL1
1 null
2 null

thanks
Bharathi


Bob Swift - 23/Apr/08 05:51 PM
Interesting. That was with Oracle using standard oracle jdbc driver? Postgres automatically shows it as {1,2,3,4}. Basically it uses a getString function and probably up to the driver as to what to show. I would be inclined to default to true if nothing (or null) is shown for various DBs. Then at least people would have the option of getting back to the previous behavior.

Bharathi Vedurumudi - 23/Apr/08 07:27 PM
Yes, I tested it in Oracle jdbc . After seeing your comments ,i am surprised too. I agree , may be we have to keep the parameter default to true.
Thanks

Bob Swift - 25/Apr/08 09:11 PM
Ok, I decided to go with default of true. Hopefully that will not cause anybody problems.

Bob Swift - 26/Apr/08 12:16 AM
This is now officially released. array expansion is defaulted to be on.