Opened 5 years ago

Closed 5 years ago

#2170 closed defect (fixed)

Problem in induced complex constructor

Reported by: Dimitar Misev Owned by: apercov
Priority: minor Milestone: 10.0
Component: qlparser Version: 9.8
Keywords: Cc:
Complexity: Medium

Description

This query works as expected:

rasql -q 'select encode(complex(a[80:90,80:90], 13c), "csv") 
          from test_grey as a' --out string

But this does not anymore so should be fixed:

rasql -q 'select encode(complex(13c, a[80:90,80:90]), "csv") 
          from test_grey as a' --out string

Both should be added to systemtest.

Attachments (1)

0001-ticket-2170-fixed-wrong-behaviour-of-complex-numbers.patch (7.1 KB ) - added by apercov 5 years ago.
Patch fixing some of the mentioned problems. (See the comments for the list of fixed queries)

Download all attachments as: .zip

Change History (19)

comment:1 by Dimitar Misev, 5 years ago

Further problem:

SELECT complex(-151s, 0us)

Results in (-151,151)

comment:2 by Dimitar Misev, 5 years ago

SELECT complex(151us, 0us)

Result: (32729,32729)

comment:3 by Dimitar Misev, 5 years ago

Some more:

SELECT complex(-4888567l, 0ul)     

result (-4888567,4888567)

SELECT complex(4888567ul, 0)

result (32729,0)

SELECT complex(4888567ul, 0ul)

result (32729,32729)

SELECT complex(4888567ul, 0)

result (32729,0)

comment:4 by Dimitar Misev, 5 years ago

another weird case:

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string

  Result element 1: (-0.201625,-0.21327)

comment:5 by apercov, 5 years ago

Status: newaccepted

comment:6 by apercov, 5 years ago

Fixed:

SELECT complex(-4888567l, 0ul)     

result (-4888567,4888567)

SELECT complex(4888567ul, 0)

result (32729,0)

SELECT complex(4888567ul, 0ul)

result (32729,32729)

SELECT complex(4888567ul, 0)

result (32729,0)

SELECT complex(-151s, 0us)
SELECT complex(151us, 0us)

by apercov, 5 years ago

Patch fixing some of the mentioned problems. (See the comments for the list of fixed queries)

comment:7 by Dimitar Misev, 5 years ago

Was this patch applied?

in reply to:  7 comment:8 by apercov, 5 years ago

Replying to dmisev:

Was this patch applied?

Yes, the patch attached to this ticket is submitted and applied. However, the ticket still contains some unresolved problems.

comment:9 by Dimitar Misev, 5 years ago

Can you summarize which queries still fail?

in reply to:  9 comment:10 by apercov, 5 years ago

Replying to dmisev:

Can you summarize which queries still fail?

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string
rasql -q 'select encode(complex(13c, a[80:90,80:90]), "csv") 
          from test_grey as a' --out string

comment:11 by Dimitar Misev, 5 years ago

Do they throw some error, can you post the output?

in reply to:  11 comment:12 by apercov, 5 years ago

Replying to dmisev:

Do they throw some error, can you post the output?

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string
Result element 1: (-0.201625,-0.21327)
rasql -q 'select encode(complex(13c, a[80:90,80:90]), "csv") 
          from test_grey as a' --out string
Executing retrieval query... rasdaman error 300: Parsing error 300 in line 1, column 28: Unexpected name a.

comment:13 by Dimitar Misev, 5 years ago

Does this work?

rasql -q 'select encode(complex(marray i in [80:90,80:90] values 13c,
                                a[80:90,80:90]), "csv")
          from test_grey as a' --out string

this one should probably throw the same error (rasdaman error 300: Parsing error 300 in line 1, column 28: Unexpected name a.)

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string

in reply to:  13 comment:14 by apercov, 5 years ago

Replying to dmisev:

Does this work?

rasql -q 'select encode(complex(marray i in [80:90,80:90] values 13c,
                                a[80:90,80:90]), "csv")
          from test_grey as a' --out string

this one should probably throw the same error (rasdaman error 300: Parsing error 300 in line 1, column 28: Unexpected name a.)

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string

First query works.
Regarding the second query the problem is different. The a is recognized, but the imaginary parts of elements are not created properly, and avg_cells doesn't work as it should in that case. If we want to throw the error (other option is to wait on fix), then I think it should be some different error. For example: avg_cells received unsupported type of argument.

comment:15 by apercov, 5 years ago

Upon further investigation, I found out that the problem lays in the usage of short in the query. The collection is too big, for its sum to be stored in the short. Therefore, the sum wraps itself around short and becomes very small. This behavior is unique to the complex types.

comment:16 by apercov, 5 years ago

Possible solution for this problem is to enforce the condense op to use CInt32 for storing the result of the sum.

comment:17 by apercov, 5 years ago

Query

rasql -q 'SELECT avg_cells(complex((short)a, 1s)) FROM test_grey AS a' --out string

is fixed.

comment:18 by Dimitar Misev, 5 years ago

Resolution: fixed
Status: acceptedclosed

Ok so I think we can close this ticket.

Note: See TracTickets for help on using tickets.