Solved

Using a featureReader Schema (Any format) for multiple Geopackage files, I get all the attributes, but how do I get the table names these attributes belong to?

  • 8 February 2023
  • 7 replies
  • 69 views

I have a workflow where I use the schema port of a FeatureReader (format Geopackage) to check if the schema of the input gpkg is correct. This works fine for a single file, fme_feature_type_name provides the table name, and I have the list of attributes.

However, if the input is more than one file, the schema is a 'global' schema combining the schemas for all input files, avoiding double tables. As a result I cannot check each file separately.

I found out that using the FeatureReader with type Schema (any Format) gives on the generic port all tables as feature, with the attributes list, for all files. But here is the problem: when using Schema (any Format) on a geopackage, these tables as feature on the generic port do not expose the table name. I expected fme_feature_type_name, but this is not available in the output. fme_feature_type gives 'schema' as value.

Is there any way I can get these table names ?

 

Thanks,

Marc

 

icon

Best answer by nielsgerrits 8 February 2023, 11:29

View original

7 replies

Userlevel 6
Badge +32

I can reproduce this.

 

What works for me is using a FeatureReader, OGC GeoPackage format, and set the parameter Schema/Data Features to Schema Features only. I then get a fme_feature_type_name for each table.

Userlevel 6
Badge +32

I can reproduce this.

 

What works for me is using a FeatureReader, OGC GeoPackage format, and set the parameter Schema/Data Features to Schema Features only. I then get a fme_feature_type_name for each table.

Attached sample workspace.

Attached sample workspace.

Hi Niels,

 

The workflow in your example is what works for 1 gpkg file in the input, but not for multiple input files. Let's say we have:

file1.gpkg

table1.id

table1.user

 

table2.id2

table2.user

 

file2.gpkg

table1.id

table1.user

 

In this case, the output will only contain 2 features, one for table1 and one for table2.

That is not enough to detect that table2 is missing in file2.gpkg.

 

kind regards,

Marc

 

Userlevel 6
Badge +32

Attached sample workspace.

Ah yes, I have seen this before. Solved it by putting the FeatureReader in a Custom transformer with group by functionality, and group by "path_windows".

Userlevel 6
Badge +32

Attached sample workspace.

Attached sample workspace.

Attached sample workspace.

Dag Niels,

 

Thank you, works perfectly! And this way of using Group by for custom transformers will be useful in other situations too.

I have to admit that in the meantime I found a simple solution for the second method I tried, working with a FeatureReader and Schema (Any format) as format. With that reader, all schema features are sent to the generic port. It is enough to add fme_feature_type_name to the "attributes to expose" setting for the generic port of the FeatureReader. It is added and contains the correct value. In this case I have to set the format to OGC Geopackage in the parameters. With the default setting (guess format name from extension) it doesn't work.

 

Thanks again, bedankt voor de hulp,

Marc

Userlevel 6
Badge +32

Attached sample workspace.

Cheers!

Reply