Skip to main content
Solved

How data types are determined by Amplitude

  • March 6, 2021
  • 1 reply
  • 1128 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.

Best answer by Saish Redkar

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!

View original
Did this topic help you find an answer to your question?

1 reply

Saish Redkar
Expert
Forum|alt.badge.img+10
  • Expert
  • 1378 replies
  • Answer
  • March 8, 2021

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


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