Thread: Using array_agg in pgr_kdisjkstrpath() error

Using array_agg in pgr_kdisjkstrpath() error

From
Marc-André Goderre
Date:
Hello all,
I hope someone will can help me.

When I use pgr_kdijkstrapath function as this:

select * FROM pgr_kdijkstrapath('
                SELECT d.id,
                         source::integer,
                         target::integer,
                         c.cost::double precision as cost
                         FROM way_topo_data d join way_cost c on d.id = c.id
                         where c.profile_id=5',
                (select n1.start_id::integer from n1),
                (select array_agg(end_id::integer)::integer[] as id from n2),
                false,
                false) p;

It return me the following error : One of the target vertices was not found or several targets are the same.

But when i take the result of the
(select array_agg(end_id::integer) ::integer[]  as id from n2)
giving me "{28411,25582}" and hardcode it in the the statement as :

select * FROM pgr_kdijkstrapath('
                SELECT d.id,
                         source::integer,
                         target::integer,
                         c.cost::double precision as cost
                         FROM way_topo_data d join way_cost c on d.id = c.id
                         where c.profile_id=5',
                (select n1.start_id::integer from n1),
                '{28411,25582}',
                false,
                false) p;

It works
Then, where's the difference between the result of (select array_agg(end_id::integer)::integer[]  as id from n2) AND
'{28411,25582}'

Thanks

Marc






Re: Using array_agg in pgr_kdisjkstrpath() error

From
"David G. Johnston"
Date:
On Thursday, April 9, 2015, Marc-André Goderre <magoderre@cgq.qc.ca> wrote:
Hello all,
I hope someone will can help me.

Then, where's the difference between the result of (select array_agg(end_id::integer)::integer[]  as id from n2) AND '{28411,25582}'

There isn't...though technically the former is an integer array and the later is an unknown literal.  It gets implicitly cast, I think, to an int[] so that it can get matched to the only? function with that name.

A self-contained example would likely help...those who are responsible for pgrouting.  The error is coming from the function so debugging it from the inside would help.

Does the order of the integers matter?

David J.