Skip to main content

Use case: Load Funnel data into Apache Cassandra with Amazon S3

Use case: export Funnel data to Amazon S3 and load CSV or TSV files into Apache Cassandra.

1. In Funnel

Create a File Share in Funnel to the destination of your choice:

​

  • S3

  • Microsoft Blob Storage

  • Google Cloud Storage

  • SFTP

​

Share your files as CSV or TSV.

​

Depending on your setup you might need to have another step to move the files to where you host your Cassandra instance.

​

2. In Cassandra

This is an example of a setup in Cassandra.
​

​

If you already have a complete setup then go to step 2.4.

​

2.1 Create a keyspace

Create a keyspace named "example" with two nodes

CREATE KEYSPACE example WITH replication = \{  
  'class': 'SimpleStrategy', 'replication_factor': 2  
\};

2.2 Use the keyspace

Use the keyspace created in the previous step

USE example;

2.3 Create a table

Create a table named "example" with two nodes

CREATE TABLE IF NOT EXISTS funnel_data (  
  date date PRIMARY KEY,  
  sourceType text,  
  sourceId text,  
  currency text,  
  common_cost float,  
  common_clicks int,  
  common_impressions int  
);

2.4 Copy the data into the table

The shared CSV/TSV file in S3 (from step 1) can now be copied into the table with a simple COPY FROM statement.

​

Important: Remember to use the option ESCAPE='"' since Funnel uses quotes as escape characters.

COPY funnel_data (  
  date,   
  sourceType,   
  sourceId,   
  currency,   
  common_cost,   
  common_clicks,   
  common_impressions  
)  
FROM 'example.csv'  
WITH ESCAPE='"';'

Done!

Your data is now stored and can be queried in your Cassandra database.

Did this answer your question?