Redimension AQL syntax error


#1

Here is an example of redimension that works under AFL but the equivalent under AQL generates a syntax error:

AFL% redimension(build(<attribute:int64>[index=0:9, 10, 0],index),
                 <index:int64>[attribute=0:9, 10,0]);

Under AQL for example,

select * into A from build(<attribute:int64>[index=0:9, 10, 0],index);
select * from redimension(A, <index:int64>[attribute=0:9, 10,0]);

yields the following syntax error message:

UserQueryException in file: src/query/parser/Driver.cpp function: fail line: 131
Error id: scidb::SCIDB_SE_PARSER::SCIDB_LE_QUERY_PARSING_ERROR
Error description: Error during query parsing. Query parser failed with error 'syntax error'.
select * from redimension(A, <index:int64>[attribute=0:9, 10,0])
             ^^^^^^^^^^^^

Does this mean that the operator redimension is only for AFL and not for AQL or is this a regression?


#2

The AQL syntax for redimension is modeled on SQL’s group by etc.

SELECT MIN ( val ) 
  FROM source 
REDIMENSION BY [ I=0:9,10, J=0:*,10000 ]; 

But your problem (I think) is that you’ve got the AFL parser turned on in the iquery tool. Try this …

SET LANG AQL;
SET FETCH;
SELECT * FROM redimension(A, <index:int64>[attribute=0:9, 10,0]);

#3

Thanks for the help but, unfortunately, I still observe the same syntax error and iquery is clearly set to AQL in my additional tests.

For the record, I was using an iquery, 14.7, that I compiled under Ubuntu 14.04. I ran the tests directly on my coordinator which is 14.7 on Ubuntu 12.04 where I used the SciDB binary packages for the installation. I obtained the same syntax error on my coordinator.

If you cannot reproduce the same syntax error, then there is something different with my environment compared to your environment but I cannot think of what it could be at the moment.


#4

Ah! Sorted it.

The ‘redimension’ token in an AQL statement is confusing things. The following little script illustrates what’s going on, and provides the AQL syntax that will get you around the problem (for now). For reference, I have created a ticket number 4292 to get the syntactical ambiguity resolved. Can’t speculate about when it will be fixed, though.

--
--   File:   Devel/Examples/Forum_Redim.aql
---
--  About:
--
--    Reproduce AQL syntax problem from the forums. 
--
-------------------------------------------------------------------------------
--
SET LANG AQL;
SET NO FETCH;
--
DROP ARRAY A;
DROP ARRAY B;
--
CREATE ARRAY A < attribute : int64>[ index=0:9, 10, 0];
--
SELECT * INTO A
  FROM build ( < attribute : int64>[ index=0:9, 10, 0], index );
--
SELECT *
  FROM redimension ( A, < index : int64 > [ attribute=0:9,10,0 ] );
--
--
-- UserQueryException in file: src/query/parser/Driver.cpp function: fail line: 132
-- Error id: scidb::SCIDB_SE_PARSER::SCIDB_LE_QUERY_PARSING_ERROR
-- Error description: Error during query parsing. Query parser failed with error 'syntax error'.
-- 
-- SELECT *
--   FROM redimension ( A, < index : int64 > [ attribute=0:9,10,0 ] )
--        ^^^^^^^^^^^^
--
--   Aaah! The problem is that the parser is confusing the 'REDIMENSION'   
--  token from the AQL syntax is getting confused with the 'redimension' 
--  operator! 
--
--   Alternative, "pure AQL" syntax...
-- 
SET FETCH;
SELECT MIN ( index ) AS index
  FROM A
 REDIMENSION BY [  attribute=0:9,10,0 ] ;
--
SELECT MIN ( index ) AS index
  INTO B
  FROM A
 REDIMENSION BY [  attribute=0:9,10,0 ] ;
--
SELECT * FROM show ( B );
--
-------------------------------------------------------------------------------

#5

Thanks for the update, workaround, and for creating the ticket.