Bug report #17300

Aggregate functions in Field Calculator in modeller

Added by Danielle G almost 3 years ago. Updated over 2 years ago.

Status:Closed
Priority:Normal
Assignee:Luigi Pirelli
Category:Processing/Modeller
Affected QGIS version:2.18.14 Regression?:No
Operating System: Easy fix?:Yes
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25198

Description

The aggregate functions in field calculator cannot calculate on a layer which is not saved to the project model.

For example, when trying to do a series of aggregate (e.g. mean, sum) calculations in the model builder, the first one (working directly off of a layer saved in the model) will work, while any subsequent calculations, based on temporary layers within the model builder calculations returns "An error occurred while evaluating the calculation string: Cannot use aggregate function in this context".

(I haven't posted issues before, hopefully this is enough detail. It is very easy to replicate -simply try to do a couple of aggregate functions in series in model builder)

layer.zip - layer (1.9 KB) Francisco Pérez Sampayo, 2017-12-20 01:21 PM

test_agg.model - qgis 2 processing model (4.73 KB) Francisco Pérez Sampayo, 2017-12-20 01:22 PM

test_agg.model3 - qgis 3 processing model (7.18 KB) Francisco Pérez Sampayo, 2017-12-20 01:22 PM

aggregation_project_21816.zip - project and files (21.7 KB) Jean-Louis Stanus, 2018-01-30 03:22 PM

Models.zip - Models (2.07 KB) Jean-Louis Stanus, 2018-01-30 03:22 PM

Associated revisions

Revision 1c34b255
Added by Luigi Pirelli over 2 years ago

Add out layer to registry before its update.

Useful only in case of use waterfall aggregate functions because they get
layer from registry basing on layer scope.

Fixes #17300
(https://github.com/qgis/QGIS/pull/5950)

History

#1 Updated by Giovanni Manghi almost 3 years ago

  • Category changed from Field calculator to Processing/Modeller
  • Subject changed from Aggregate functions in Field Calculator to Aggregate functions in Field Calculator in modeller

#2 Updated by Francisco Pérez Sampayo almost 3 years ago

I can confirm this bug on 2.18.14

#3 Updated by Giovanni Manghi almost 3 years ago

  • Affected QGIS version changed from 2.18.11 to 2.18.14

#4 Updated by Francisco Pérez Sampayo almost 3 years ago

I just test this bug with master and works ok without problem on aggregates.
I send the layer and the models for the versions 2 and 3 i you want to replicate faster.

#5 Updated by Luigi Pirelli almost 3 years ago

trying to replicate on linux

#6 Updated by Luigi Pirelli almost 3 years ago

  • Assignee set to Luigi Pirelli

replicated on linux with lates 2.18 b06f99b

#7 Updated by Luigi Pirelli almost 3 years ago

  • Pull Request or Patch supplied changed from No to Yes

#8 Updated by Luigi Pirelli over 2 years ago

  • Assignee changed from Luigi Pirelli to Victor Olaya

changed assignee trying to speedup review or merge of proposed PR

#9 Updated by Luigi Pirelli over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#10 Updated by Jean-Louis Stanus over 2 years ago

Hello,

I tested with nightly 2.18.16-5 (installed with osgeo4w). It looks not solved.

I created
  • a model with refactor inwhich i use aggregate( ... input : merged_only_by_model
  • a second where i merge 2 layers THEN i refactor inwhich i use aggregate( ... input : couche2 and couche1

The first works, the second with the same layer not because refactor with aggregate is used in second (or more) place

UPDATE: yes, typo. Fixed ;)

#11 Updated by Luigi Pirelli over 2 years ago

  • Assignee changed from Victor Olaya to Luigi Pirelli

I'll give a check, tnx for the report

I suppose it's a typo... you where talking about 2.18.16-5 is it right?

#12 Updated by Luigi Pirelli over 2 years ago

Hi Jean-Louis
The Aggregate function you are using in "test aggregate only" model is a "refactor fields" qgis alg that has not relation with aggregate functions. The only relation is the name that is set manually in the model.

The "test merge and aggregate" model depend on saga (that I've not installed) do you mind to prepare a test case that use ONLY base algorithm not depending by third party backends? I've error reading the algorithm because lack of SAGS.
BTW, merge algorithm is not (AFAIK) an aggregate function.

all this to say that your report seems related to something not related with the issue that has been fixed.

I leave the issue closed until a reproducible and related test case can confirm that the fix is not working.

regards

#13 Updated by Giovanni Manghi over 2 years ago

  • Easy fix? changed from No to Yes
  • Resolution set to fixed/implemented

Also available in: Atom PDF