Skip to main content

Data Type

About 3 min

Data Type

Basic Data Type

IoTDB supports the following data types:

  • BOOLEAN (Boolean)
  • INT32 (Integer)
  • INT64 (Long Integer)
  • FLOAT (Single Precision Floating Point)
  • DOUBLE (Double Precision Floating Point)
  • TEXT (String)

The time series of FLOAT and DOUBLE type can specify (MAX_POINT_NUMBER, see this page for more information on how to specify), which is the number of digits after the decimal point of the floating point number, if the encoding method is RLE or TS_2DIFF. If MAX_POINT_NUMBER is not specified, the system will use float_precision in the configuration file iotdb-engine.properties.

  • For Float data value, The data range is (-Integer.MAX_VALUE, Integer.MAX_VALUE), rather than Float.MAX_VALUE, and the max_point_number is 19, caused by the limition of function Math.round(float) in Java.
  • For Double data value, The data range is (-Long.MAX_VALUE, Long.MAX_VALUE), rather than Double.MAX_VALUE, and the max_point_number is 19, caused by the limition of function Math.round(double) in Java (Long.MAX_VALUE=9.22E18).

When the data type of data input by the user in the system does not correspond to the data type of the time series, the system will report type errors. As shown below, the second-order difference encoding does not support the Boolean type:

IoTDB> create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF
error: encoding TS_2DIFF does not support BOOLEAN

Timestamp

The timestamp is the time point at which data is produced. It includes absolute timestamps and relative timestamps

Absolute timestamp

Absolute timestamps in IoTDB are divided into two types: LONG and DATETIME (including DATETIME-INPUT and DATETIME-DISPLAY). When a user inputs a timestamp, he can use a LONG type timestamp or a DATETIME-INPUT type timestamp, and the supported formats of the DATETIME-INPUT type timestamp are shown in the table below:

Supported formats of DATETIME-INPUT type timestamp

Format
yyyy-MM-dd HH:mm:ss
yyyy/MM/dd HH:mm:ss
yyyy.MM.dd HH:mm:ss
yyyy-MM-dd HH:mm:ssZZ
yyyy/MM/dd HH:mm:ssZZ
yyyy.MM.dd HH:mm:ssZZ
yyyy/MM/dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss.SSS
yyyy.MM.dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss.SSSZZ
yyyy/MM/dd HH:mm:ss.SSSZZ
yyyy.MM.dd HH:mm:ss.SSSZZ
ISO8601 standard time format

IoTDB can support LONG types and DATETIME-DISPLAY types when displaying timestamps. The DATETIME-DISPLAY type can support user-defined time formats. The syntax of the custom time format is shown in the table below:

The syntax of the custom time format

SymbolMeaningPresentationExamples
Geraeraera
Ccentury of era (>=0)number20
Yyear of era (>=0)year1996
xweekyearyear1996
wweek of weekyearnumber27
eday of weeknumber2
Eday of weektextTuesday; Tue
yyearyear1996
Dday of yearnumber189
Mmonth of yearmonthJuly; Jul; 07
dday of monthnumber10
ahalfday of daytextPM
Khour of halfday (0~11)number0
hclockhour of halfday (1~12)number12
Hhour of day (0~23)number0
kclockhour of day (1~24)number24
mminute of hournumber30
ssecond of minutenumber55
Sfraction of secondmillis978
ztime zonetextPacific Standard Time; PST
Ztime zone offset/idzone-0800; -08:00; America/Los_Angeles
'escape for textdelimiter
''single quoteliteral'

Relative timestamp

Relative time refers to the time relative to the server time now() and DATETIME time.

Syntax:

 Duration = (Digit+ ('Y'|'MO'|'W'|'D'|'H'|'M'|'S'|'MS'|'US'|'NS'))+
 RelativeTime = (now() | DATETIME) ((+|-) Duration)+
       

The syntax of the duration unit

SymbolMeaningPresentationExamples
yyear1y=365 days1y
momonth1mo=30 days1mo
wweek1w=7 days1w
dday1d=1 day1d
hhour1h=3600 seconds1h
mminute1m=60 seconds1m
ssecond1s=1 second1s
msmillisecond1ms=1000_000 nanoseconds1ms
usmicrosecond1us=1000 nanoseconds1us
nsnanosecond1ns=1 nanosecond1ns

eg:

now() - 1d2h //1 day and 2 hours earlier than the current server time
now() - 1w //1 week earlier than the current server time

Note:There must be spaces on the left and right of '+' and '-'.

Copyright © 2024 The Apache Software Foundation.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.

We use Google Analytics to collect anonymous, aggregated usage information.