Skip to main content
Question

ChangeDetector: Original port truncates varchar


jayqueue
Forum|alt.badge.img

Hello,

Situation:

I connect to an API on a daily basis and write that data back to a SQL server.

The API returns a JSON with also a modificationDate. With the ChangeDetector I check if there's a change on that date, if so Update the attributes.

But I thought there were a lot of updates so I added a list to check what.

 

Here we can we can see that OriginalValue is trimmed where as revisedValue is not.

 

The OriginalValue source:

And the RevisedValue source:

 

Both look the same to me, so how can it be the data is cut off?

I'm not doing anything with it, just reading it straight from the DB?

Sincerely,

 

Jonathan

14 replies

david_r
Evangelist
  • December 5, 2019

How the values are returned from the database depends on the data type used in the underlying database table. There are notably some timestamp data types that do not store milliseconds or time zone information, which may be why your data lacks them when reading it back.

My recommendation is that you use the DateTimeConverter on both input sources to set them to the exact same format before using the ChangeDetector.


jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019
david_r wrote:

How the values are returned from the database depends on the data type used in the underlying database table. There are notably some timestamp data types that do not store milliseconds or time zone information, which may be why your data lacks them when reading it back.

My recommendation is that you use the DateTimeConverter on both input sources to set them to the exact same format before using the ChangeDetector.

Even when they are varchar?

But I'll try with the DateTimeConverter, thanks! :-)


david_r
Evangelist
  • December 5, 2019

If the storage data type is varchar, then it seems something is truncating your string. Are there any warnings in the FME log when writing the time stamps? How long is the varchar in the table definition, is it long enough?

 

 


jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019

In the MS-SQL db it's ok

0684Q00000ArJjTQAV.png

 

in the data inspector both modificationDate's are fme_varchar as well

There are no warnings in the logs.

Checked with a Logger.

RevisedValue (from API)

Attribute(encoded: UTF-8): `modificationDate' has value `2019-12-03T07:54:20.000+0000'

OriginalValue (from DB)

Attribute(encoded: UTF-16LE): `modificationDate' has value `2019-12-03T08:08:17.000+0000'

The only thing I see is the encoding, could that be an issue?

Update:

AttributeEncoder works but does not help :-)

Attribute(encoded: UTF-8)   : `modificationDate' has value `2019-12-03T08:14:46.000+0000'

 


david_r
Evangelist
  • December 5, 2019

The encoding should be OK, as long as both are in some sort of UTF (unicode) variant then it shouldn't be a problem. Anyways, I don't suppose you have any special characters in the time stamps.

How is the time stamp text field defined in the FME reader? Does it correspond to the database table definition? Perhaps try recreating the reader.

If that doesn't help, try inspecting the reader output before any of the other transformers.


jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019
david_r wrote:

The encoding should be OK, as long as both are in some sort of UTF (unicode) variant then it shouldn't be a problem. Anyways, I don't suppose you have any special characters in the time stamps.

How is the time stamp text field defined in the FME reader? Does it correspond to the database table definition? Perhaps try recreating the reader.

If that doesn't help, try inspecting the reader output before any of the other transformers.

In the reader it's defined varchar(30), same as in DB.

recreated it but no difference.

The logger/inspector were connected directly to the reader, there it was just fine. The moment it hits the ChangeDetector it's fubar.

So for the fun of it I swithced Orignal and Revised ports and guess what, now the API is truncated with the Original Port.

Could it be a bug?


david_r
Evangelist
  • December 5, 2019
jayqueue wrote:

In the reader it's defined varchar(30), same as in DB.

recreated it but no difference.

The logger/inspector were connected directly to the reader, there it was just fine. The moment it hits the ChangeDetector it's fubar.

So for the fun of it I swithced Orignal and Revised ports and guess what, now the API is truncated with the Original Port.

Could it be a bug?

That's really strange. What FME version is this?


jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019
david_r wrote:

That's really strange. What FME version is this?

2019.0.2.0 (20190605 - build 19260)


david_r
Evangelist
  • December 5, 2019
jayqueue wrote:

2019.0.2.0 (20190605 - build 19260)

I'm unable to reproduce anything like it using FME 2019.2.1.

Can you reproduce the issue with a minimal workspace and post it here?

Are you able to try upgrading to 2019.2.1 and try again?

jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019
david_r wrote:

I'm unable to reproduce anything like it using FME 2019.2.1.

Can you reproduce the issue with a minimal workspace and post it here?

Are you able to try upgrading to 2019.2.1 and try again?

It's working now but I found that when I use a certain attribute in

Attribute Matching strategy -> Selected Attributes the modificationDate is truncated; If I dont't use that attribute it works like a charm?


david_r
Evangelist
  • December 5, 2019
jayqueue wrote:

It's working now but I found that when I use a certain attribute in

Attribute Matching strategy -> Selected Attributes the modificationDate is truncated; If I dont't use that attribute it works like a charm?

Without seeing the workspace and the data it's very difficult to say, but in general I find that behavior surprising. I would consider opening a support case with Safe.


jayqueue
Forum|alt.badge.img
  • Author
  • December 5, 2019
david_r wrote:

Without seeing the workspace and the data it's very difficult to say, but in general I find that behavior surprising. I would consider opening a support case with Safe.

David, thank your for the feedback!


bruceharold
Contributor
Forum|alt.badge.img+17
  • Contributor
  • December 5, 2019
david_r wrote:

How the values are returned from the database depends on the data type used in the underlying database table. There are notably some timestamp data types that do not store milliseconds or time zone information, which may be why your data lacks them when reading it back.

My recommendation is that you use the DateTimeConverter on both input sources to set them to the exact same format before using the ChangeDetector.

Yes this is what I do when comparing times across differing systems of record, cast the values to a common precision like %Y%m%d%H%M%S


jayqueue
Forum|alt.badge.img
  • Author
  • December 9, 2019
bruceharold wrote:

Yes this is what I do when comparing times across differing systems of record, cast the values to a common precision like %Y%m%d%H%M%S

Normally yes, but the data is stored as varchar.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings