Solved

In what order feature are read through a reader in FME 2016 ?

  • 19 April 2016
  • 5 replies
  • 10 views

Badge

I have a script with one database (PostGIS, Oracle or SQL Server) reader and with a PythonCaller which depends on the order of the features. I run my script with FME 2016 and noticed that the order of features is different.

So i wonder if something change deliberately or the order depend on something that FME can't control ? I didn't see a related subject in the changelog of the 2016 release.

icon

Best answer by redgeographics 19 April 2016, 15:18

View original

5 replies

Userlevel 5
Badge +26

Usually it's the order in which the features (records) are returned by the database. And that's either the order in which they're stored or in which they're ordered by an SQL query (SELECT * FROM bla ORDER BY something). So yes, it might be out of FME's control.

If you run the workpace with 2015 and 2016 right after eachother, do you see different results?

Userlevel 2
Badge +16

The order of reader could be controlled previous to FME 2016 (is the order in which the readers appear in the Navigation window), but not the order of the feature types.

This has changed in FME 2016.1.

The order of reading feature type can be controlled in that version too (see the recorded webinar).

Badge

Usually it's the order in which the features (records) are returned by the database. And that's either the order in which they're stored or in which they're ordered by an SQL query (SELECT * FROM bla ORDER BY something). So yes, it might be out of FME's control.

If you run the workpace with 2015 and 2016 right after eachother, do you see different results?

Without an ORDER BY databases are free to return rows in any order, with no guarantee of the same ordering even for back-to-back invocations of the same query. (In practice you'll usually get a predictable order, just don't count on it.)

Either writing custom SQL with an ORDER BY or adding a Sorter transformer could give the needed stability.

Userlevel 2
Badge +16

The order of reader could be controlled previous to FME 2016 (is the order in which the readers appear in the Navigation window), but not the order of the feature types.

This has changed in FME 2016.1.

The order of reading feature type can be controlled in that version too (see the recorded webinar).

Sorry, I did not read as well as I should.

The order of features read depend on the SQL statement.

If you want change that you can add the ORDER BY clause in the WHERE Clause parameter of the reader or the feature type.

Alternatively you could use the SQLCreator as a reader and create your specific SQL statement.

Badge

Thank you all for your answers.

redgeographics: Yes I see a difference when i run a workspace with 2015 and 2016. So maybe the reader use a different SQL query to retrieve features, because my database use its indexes to return rows so the order do not change if there is no modification, moreover running my script with 2015 give me the same result everytime.

Anyway I still have to order features myself if I want a script which create the same result on all FME versions.

Reply