A common setup for batch loading files into Ocient is to load from a bucket on S3 with time partitioned data. In many instances, a batch load is performed on a recurring basis to load new files. The LAT transforms each document into rows in one or more different tables. Ocient’s Loading and Transformation capabilities use a simple SQL-like syntax for transforming data. This tutorial will guide users through a simple example load using a small set of data in CSV format. The data in this example is created from a test set for the Business Intelligence tool.Documentation Index
Fetch the complete documentation index at: https://docs.ocient.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
This tutorial assumes that:- The Ocient System has network access to S3 from the Loader Nodes.
- An Ocient System is installed and configured with an active storage cluster (See the Ocient Application Configuration guide).
- Loading and Transformation is installed on the Loader Nodes.
- A default “sink” for the Ocient Loader Nodes is configured on the system.
- The LAT Client Command Line Interface is installed.
Step 1: Create a New Database
To begin, load two example tables in a database. First, connect to a SQL Node using the Commands Supported by the Ocient JDBC CLI Program. Then run the following DDL command:SQL
Step 2: Create Tables
To create tables in the new database, first connect to that database (e.g.,connect to jdbc:ocient://sql-node:4050/metabase), then run the following DDL commands:
SQL
Step 3: Create a Data Pipeline
Data pipelines are created using a simple loading configuration that is submitted to the Transformation Nodes to start loading. File Groups designate a batch of files to load. Each File Group is routed to one or more Ocient tables, and each column is the result of a transformation applied to the source document. First, inspect the data that you plan to load. Each document has a format similar to the following example:Text
JSON
**orders*.csv then they would all be part of the file group. You do not need S3 credentials because this is a public bucket, but if it were private, you can supply credentials in a few different ways.
Next, note the extract section. Here, the example specifies a delimited format. If it were compressed (e.g., gzip), you could specify compression. The example also specifies the headers to associate with each column in the CSV data. Delimited extracts can specify different record delimiters (e.g., \n), specify field delimiters (e.g., |, \t, ,), define how to handle empty fields or to trim whitespace, and specify strings that should be considered NULL. While not used in this file, an example of null strings is provided that would turn the string literal “NULL” or “N/A” into a database NULL.
The final parameter supplied in the example is the sort type for the file load. This informs the LAT how you would like data to be ordered when loading. The ideal sort organizes files in time order according to the defined . This makes more efficient segments and is much faster to load. This example uses the lexicographic sort which orders according to the characters in the file name. Other sort types are available to use file modified time or to extract the timestamp for sorting from the file path or file name.
Step 4: Using the Loading and Transformation CLI
With a pipeline.json file ready to go, you can test this pipeline. To test, use the LAT CLI. For these examples, assume that two LATs are configured and set using an environment variable. First, configure the LAT CLI to use the hosts of the Ocient Loading and Transformation service. You can add these to every CLI command as a flag, but for simplicity you can also set them as environment variables. From a command line, run the following command replacing the IP addresses with the IP addresses of your LAT processes:Shell
If your LAT is running without TLS configured, replace the port number of your LAT Hosts with 8080 and the protocol with
http://.Shell
Bash
--no-verify flag if certificate validation fails.
Step 5: Test the Transformation
The CLI supports previewing a transformation with an example document and the pipeline file. This makes it easy to test your transformations. First, save an example document to your file system to use for this test. For this demo, you can download an example file from https://ocient-docs.s3.amazonaws.com/metabase_samples/csv/orders.csv and save it to~/orders.csv.
Next, make sure the pipeline.json file that you created is stored at ~/pipeline.json.
Now that both files are available, you can run the CLI to preview the results. Pass the preview command the topic name, the pipeline file, and the sample record file. The response contains the transformed data tied to the destination table and a list of any error records.
Similar to how you can preview records on a topic for file loads, you can supply any one file_groups created in the extract section to preview the transformations.
Shell
JSON
recordErrors object. You can quickly update the pipeline.json file and preview again. Now, you can inspect different documents to confirm that various states of data cleanliness like missing columns, null values, and special characters are well handled by your transformations.
Step 6: Configure and Start the Data Pipeline
With a tested transformation, the next step is to setup and start the data pipeline. First, configure the pipeline using thepipeline create command. This validates and creates the pipeline, but will not take effect until you start the pipeline:
Shell
Bash
In cases where there is an existing pipeline operating, it is necessary to stop the pipeline and remove the original pipeline before creating and starting the new pipeline.
pipeline start commands:
Shell
Bash
Step 7: Confirm that Loading is Operating Correctly
With your pipeline in place and running, data will immediately begin loading from the S3 file groups that you defined. If there were many files per file group, the LAT would first sort the files, then partition them for the fastest loading based on the sorting criteria you provided.Observing Loading Progress
With the pipeline running, data immediately begins to load into Ocient. To observe this progress, you can use thepipeline status command from the LAT Client or monitor the LAT metrics endpoint of the Loader Nodes.
You can check the status with this command by using the --list-files flag to include a summary of the files included in the load.
Shell
Bash
CURL
If your LAT is running without TLS configured, replace the port number of your LAT Hosts with 8080 and the protocol with
http://.JSON
Check Row Counts in Tables
To confirm that you are seeing results in the target tables, you can also run some simple queries to check row counts. Depending on the streamloader role settings, the time for records to become queryable can vary from a few seconds to minutes: Example Queries:SQL
SQL
Check Errors
In this example, all rows load successfully. However, a successful load does not always happen, and you can inspect errors using the LAT Client. Whenever the LAT process fails to parse a file correctly or fails to transform or load a record, the LAT process records an error. The LAT Client includes thelat_client pipeline errors command that reports the latest errors on the pipeline.
A full error log is available on the Loader Nodes. These logs report all bad records and the reason that the load fails.
When you load a pipeline from Kafka, the load might route errors to an error topic on the Kafka broker instead of the logs. The LAT Client does not contain the errors sent to the error topic. You can inspect these errors with Kafka utilities instead.
time1 column. Options exist on the pipeline errors command to return JSON and to restrict the response to specific components of the error detail that includes a reference to the source location of this record.
The following command returns JSON that is delimited with newline characters. You can pass the JSON output to jq or a file. The JSON includes the source topic or file group, the filename where the error occurred, the offset that indicates the line number or Kafka offset, and the exception message that aids in troubleshooting and identifying the incorrect record in the source data. You can use the log_original_message pipeline setting to provide direct access to the parsed source record for errors when appropriate.

