How to use aliasing with AFL?


#1

I want to cross_join two arrays A, B which have same name of dimensions, defined as

A: <cntid:uint64 NULL DEFAULT null> [hid=0:,1000000,0,hid_2=0:,1000000,0]’,true
B: <cntid:uint64 NULL DEFAULT null> [hid=0:*,1000000,0]’,true

So cross_join(A,B,hid_2,hid) where hid_2 is from array A and hid is from B.

Now it is obvious that hid is from array B, yet I get the "Error description: Query syntax error. Dimension ‘hid’ is ambiguous."
Agreed hid is in array A, but documentation says “cross_join(left_array,right_array,left_dim1,right_dim1,…)”

Why is this so? Can I alias these arrays some how as in AQL: “select * into TEMP from A as a JOIN B as b on a.hid_2 = b.hid”

Makes me think, AQL semantics are neat in this case, but AFL is not.
For AFL, I have been materializing the result of cross_join(A,B) and then filtering to do hid_2 = hid_3 where hid_3 belongs to B.
This is not efficient.

I am aware of attribute rename. Is there a dimension rename or am I doing something wrong?

Also orthogonal question: is there any difference between AFL and AQL (semantics and performance-wise) or are they two sides of the same coin? When should one use one over the other?

Thanks much in advance!!


#2

Indeed it is quirky. More quirky than it needs to be. We’re in the process of overhauling the language.

cross_join( A, B, A.hid_2, B.hid)

Or

cross_join( A as array1, B as array2, array1.hid_2, array2.hid)

AFL tends to be a lot more precise. AQL semantics are translated into AFL but at the moment the translations are not very efficient. The most user-friendly way to program SciDB at the moment is SciDB-R and SciDB-Py. The fastest and most precise is AFL.
To do dimension-rename, see the documentation for cast().