Question

Where Clause from Attribute value in SchemaMapper not working (Microsoft SQL Server Non-Spatial)

  • 23 October 2017
  • 4 replies
  • 1 view

Badge

I am trying to read in the SchemaMapper from a Microsoft SQL Server Non-Spatial table based on a where clause. The value in the where clause depends on the value from another table. So I first read that other table and create an attribute with that value. In the SchemaMapper the configuration is as follows:

You can already notice that there are no options to assign an attribute value or open a text editor for the WHERE Clause field.

When I run the workspace I get the following error:

Microsoft SQL Server Non-Spatial Reader: Query failed, possibly due to a malformed statement. Query Text `SELECT * FROM DataOwner.[RAC_SCHEMA_DEFINITION] WHERE MAPPING_ID = '@Value(MAPPING_ID)''. Provider error `(-2147217900) Conversion failed when converting from a character string to uniqueidentifier.'

 

A fatal error has occurred. Check the logfile above for details

 

SchemaMapper_Mapper(SchemaMappingFactory): Could not read feature: A fatal error has occurred. Check the logfile above for details

I appears that it is not possible to assign an attribute value inside the where clause. It just inserts the @Value(...) as text. When I try this inside a FeatureReader for Microsoft SQL Server Non-Spatial it is possible to assign an attribute value or open a text editor and running it works like a charm.

Is this a bug or non-existent functionality? Or is there a reason that this is not possible?

I am already thinking of a workaround.

 

Option is using a parameter.

 

Populating the parameter with an @Value(...) will give the same result as the above issue.

 

It appears to work with a pre-defined string as input parameter and using $() inside the SchemaMapper where clause. Problem is that the value is than not dynamic anymore.

 

I could look into catching the wanted value with Python inside the parameter, but I would like to minimize Python/arcpy.

Other option is adding (a) row(s) to the input data for the SchemaMapper and using a SchemaMapper filter instead of a where clause. This could work, but input data can have an amount of rows order of millions of rows, so I would like to avoid adding an attribute to that data. Also the mapping table for the SchemaMapper could have many rows that I won't need and I would like to avoid processing these.

Any other options? Or explanation to my earlier question?


4 replies

Userlevel 4
Badge +13

Hi @g_karssenberg, thank you for posting this. We have an existing problem report which asks for the ability to reference an attribute value in the WHERE clause of the SchemaMapper. I've made a note on PR30590 that you've submitted this as a post on our Q&A; forum. I'll update you here when the problem report is resolved.

Badge

Hi @g_karssenberg, thank you for posting this. We have an existing problem report which asks for the ability to reference an attribute value in the WHERE clause of the SchemaMapper. I've made a note on PR30590 that you've submitted this as a post on our Q&A; forum. I'll update you here when the problem report is resolved.

Thank you @TiaAtSafe. For now I will test the workaround with adding columns and using the SchemaMapper Filter. Is there a way that I can track this problem report to stay up to date about the progress and expected fix date?

 

Badge

Hi @g_karssenberg, thank you for posting this. We have an existing problem report which asks for the ability to reference an attribute value in the WHERE clause of the SchemaMapper. I've made a note on PR30590 that you've submitted this as a post on our Q&A; forum. I'll update you here when the problem report is resolved.

I assume this doesn't work in 2016.1 for SchemaMapper? This will be a pain, as I'll now need a TestFilter with 13 values along with the same number of SchemaMappers.

 

Badge

In FME 2018.0.1 I was able to use an Published Parameter within the WHERE clause of the SchemaMapper. By wrapping the SchemaMapper within an custom transformer you're able to use an attribute value.

Reply