Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

External applications also can ingest json data to chango. For example, external applications like spark streaming application consumes json from kafka and then send these streaming json data to chango. For such cases, chango provides Chango Client API Library written in java.

Download Chango Client API Library

Download chango client library. It needs to be added to your application classpath.

Code Block
curl -L -O https://github.com/cloudcheflabs/chango-client/releases/download/1.01.0/chango-client-1.01.0-executable.jar;

Create Iceberg Table before sending json to chango

As seen in ingestion of json to chango using Chango CLI https://mykidong.atlassian.net/wiki/spaces/CHANGOCLOUD/pages/2212724750/Chango+CLI#Create-Iceberg-Table-before-Json-Data-Ingestion , you need to create iceberg table beforehand.

Example of sending json to chango using Chango Client Library

You may construct chango client instance like this.

Code Block
import comco.cloudcheflabs.chango.client.component.ChangoClient;

...


String adminServer = "https://chango-admin-oci.cloudchef-labs.com";
String user = "user1";
String password = "anypassword";
String dataApiServer = "https://chango-data-api-jetty-oci-user1.cloudchef-labs.com";
int batchSize = 10000;
long interval = 1000;
String schema = "iceberg_db";
String table = "test_iceberg";

ChangoClient changoClient = new ChangoClient(adminServer,
        user,
        password,
        dataApiServer,
        schema,
        table,
        batchSize,
        interval);      

...

Code Block
        String json = ... 
       // add json coming from your application to the internal queue in chango client.    
       changoClient.add(json);

Query Iceberg Table using Trino Clients

Json data ingested to iceberg table in chango can be queries using trino clients like Trino CLI, Redash and Metabase.

...