Solved

How data types are determined by Amplitude

  • 6 March 2021
  • 1 reply
  • 810 views

Hello,

I would like to understand a bit better how data types are determined for event properties & user properties.

What if I send a property as string the first time, and then send all the following thousand events with the same property as number.

Will the data type change to number or will it stay as string?

 

Thanks.

icon

Best answer by Saish Redkar 8 March 2021, 17:01

View original

1 reply

Userlevel 7
Badge +10

Hey @gadeji 

Amplitude will ingest the data to whatever datatype you are specifying for your custom event/user property value when using their SDKs or the HTTP API. From what I have observed, the property value behavior doesn't change in UI or the property dropdown in the charts irrespective of whether it is sent as a string or a number.

If you send a property as a string the first time, and then send all the following thousand events with the same property as number, there isn't any place in UI that would differentiate those values as a string vs a number , except the raw json event view. The only place you can notice a change will be in the "raw" event view in the event stream wherein the property value for subsequent events will be shown as a number value i.e not enclosed in the " "

e.g. "song_count": "41" ( when you send the value as a string )

vs.

"song_count": 71 ( when you send the value as a number )

 

Amplitude's Govern feature can enable you to perform type checking for event and user property values if that is something you would like to use to have a better control of governing the datatypes. It can detect when event data comes in that does not match the specified type and you can set and edit the data type of an event or user property. Based on this you can trigger schema violations and tell Amplitude how to handle these situations by configuring your schema settings.

Hoping that I have understood your question correctly!

Let me know if this helps!

Reply