The current plan generated from translating a FLWOR expression produces a
type error. The issue relates to the field values being passed into the
series of operators used to generate the Where clause. The where clause
consists of a SELECT operator with a predicate function and several ASSIGN
operators used to by the predicate function. A predicate typically includes
fn:boolean and a value comparison. The value comparison needs a single item
parameter. Below is an example sequence of operators in the default plan.
select (function-call: vxquery:{
http://www.w3.org/2005/xpath-functions}boolean, Args:[%0->$$26]) --
|UNPARTITIONED|
assign [$$26] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}value-ne,
Args:[function-call: vxquery:{urn:org.apache.vxquery.operators-ext}promote,
Args:[function-call: vxquery:{http://www.w3.org/2005/xpath-functions}data,
Args:[%0->$$24], {http://www.w3.org/2001/XMLSchema}int QUANT_ONE(bytes[5] =
[1d00000002])], function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}promote, Args:[function-call:
vxquery:{http://www.w3.org/2005/xpath-functions}data, Args:[%0->$$25], {
http://www.w3.org/2001/XMLSchema}int QUANT_ONE(bytes[5] = [1d00000002])]]]
-- |UNPARTITIONED|
assign [$$25] <- [{
http://www.w3.org/2001/XMLSchema}string QUANT_ONE(bytes[7] =
[04000435302e30])] -- |UNPARTITIONED|
assign [$$24] <- [function-call:
vxquery:{urn:org.apache.vxquery.operators-ext}sort-distinct-nodes-asc-or-atomics,
Args:[%0->$$23]] -- |UNPARTITIONED|
The issue is related to the value of $23. If this value is a XQuery
sequence, the type error is thrown protecting the value-ne function from
invalid parameters.
The issue could be resolved by wrapping the Where clause in a subplan that
iterators over all values. A sequence at the end of the subplan would bring
all the value back into a similar structure for the next operator.
Is this the correct solution or is this an issue with a different part of
the FLWOR translation?