questdb

How can I send IPv4 data type using QuestDB Java Sender?


I am trying to use QuestDB Sender from Java, one of my columns is IP address. How can I send it, there seems to be no option for IPv4, there is no choice for IPv4, only doubleColumn, symbol, longColumn methods.

sender.table("weather_sensor")
                        .symbol("id", "dubai2" + i%100)
                        .longColumn("temperature", 41)
                        .doubleColumn("humidity", 0.34)
                        .atNow();

Can I send IPv4 column types?


Solution

  • You can send IPv4 as String.

    The longer answer is that QuestDB client sends the data using Influx Line Protocol. Influx line protocol is has limited types, e.g.

    QuestDB supports more types. In order to for example send IPv4 one should create table with IPv4 first connecting via web console or Postgres protocol:

    CREATE TABLE weather_sensor (ip IPV4, ts timestamp) timestamp(ts) partition by DAY WAL;
    

    and then it's possible to send STRING values into ip column using Sender:

    sender.table("weather_sensor")
       .stringColumn("ip", "127.0.0.1")
       .atNow();
    

    Here is the type compatibility list: