Opened 8 years ago

Closed 7 years ago

#1269 closed defect (fixed)

csv output of scalars is wrong

Reported by: Dimitar Misev Owned by: bbell
Priority: minor Milestone: 9.4
Component: rasql Version: development
Keywords: Cc: Peter Baumann, Bang Pham Huu
Complexity: Medium

Description (last modified by Dimitar Misev)

csv encoding of a scalar includes braces in the output, however it will be more correct if it doesn't. If we think of scalar as 0D, then its csv output is now equivalent to that of 1D array, which is wrong.

$ rasql -q 'select csv(1)' --out string --quiet
{1}
$ rasql -q 'select csv(<[0:0] 1>)' --out string --quiet
{1}

The correct output of the scalar encoding should be:

$ rasql -q 'select csv(1)' --out string --quiet
1

Change History (17)

comment:1 by Dimitar Misev, 8 years ago

Description: modified (diff)

comment:2 by Rubin Deliallisi, 8 years ago

The problem is not actually in the rasql component. All rasql does is parse the query and then display the result set. The rasodmg module is responsible for populating the result set(including the brackets).

comment:3 by Dimitar Misev, 8 years ago

Can you give more details? I can do this query as well and don't see any parentheses:

rasql -q 'select oid(mr) from mr' --out string 
  Result element 1: 82945

comment:4 by Rubin Deliallisi, 8 years ago

The result of the first(csv) query is an array type, while the result of the second one is a scalar type. These types are determined by the server. In the rasql component the format of the data is not considered at all when displaying it. Even the brackets are put into the result in the server.

comment:5 by Dimitar Misev, 8 years ago

This one is also resulting in 1D char arrays, but they are not wrapped in { }

rasql -q 'select c from RAS_COLLECTIONNAMES AS c' --out string

comment:6 by Rubin Deliallisi, 8 years ago

Yes, but those 1D char arrays are determined on the server.

rasql -q 'select c from RAS_COLLECTIONNAMES AS c' --out string

For the above query we get 13 char arrays from the server none of which has a {}. While for the csv query we just get 1 char array containing {1}. Rasql only puts the chars on a stream, because a char array has no cardinality. The array values are determined elsewhere. I am already looking on what component this happens

comment:7 by Dimitar Misev, 8 years ago

Did you check in the conversion/csv.cc? rasql of course doesn't do much, it just sends the query and gets back the result.

comment:8 by Rubin Deliallisi, 8 years ago

Yes, I have narrowed down the problem to that. Fix in progress.

comment:9 by Dimitar Misev, 8 years ago

Hi Rubin, did you manage to fix it?

comment:10 by Dimitar Misev, 8 years ago

Owner: changed from Rubin Deliallisi to Sulav Timilsina
Status: newassigned

comment:11 by Dimitar Misev, 7 years ago

Owner: changed from Sulav Timilsina to Dimitar Misev

comment:12 by Dimitar Misev, 7 years ago

Owner: changed from Dimitar Misev to bbell

comment:13 by Dimitar Misev, 7 years ago

Milestone: 9.29.4

comment:14 by Peter Baumann, 7 years ago

hm, strange - isn't CSV all about {…}?
where can we see the complete, exact specification of CSV output?

comment:15 by Dimitar Misev, 7 years ago

I'm sure we agree that the CSV output of a scalar and 1D array of single element should be different? Currently they are of the same form.

comment:16 by Dimitar Misev, 7 years ago

I mean this is really low priority ticket, output of scalars is not really important, but getting the formatting right would be good.

The JSON encode/decode algorithm in SQL/MDA provides the exact specification (just substitute [..] with {..}). JSON of scalar SQL value is only scalar of course, with no [..] around it.

comment:17 by Dimitar Misev, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.