Apache NIFI SQL Lookup Service
NiFi SQL Lookup Services Bundle allows you to so SQL for your NiFi LookupRecord and LookupAttribute needs.
For background, read:
Before you use the service you are going to need to compile it.
First grab the source code from github:
>> git clone https://github.com/mrcsparker/nifi-sqllookup-services-bundle.git
Second compile the code:
>> cd nifi-sqllookup-services-bundle
>> mvn package
Third add the compiled NiFi nars to your local NiFi install:
>> cp ./nifi-sqllookup-services-nar/target/nifi-sqllookup-services-nar-1.10.0.nar /PATH/TO/NIFI/lib
>> cp ./nifi-sqllookup-services-api-nar/target/nifi-sqllookup-services-api-nar-1.10.0.nar /PATH/TO/NIFI/lib
Finally startup NiFi:
>> cd /PATH/TO/NIFI
>> ./bin/nifi.sh run
You are ready to go!
There are two NiFi controllers in the SQL Lookup Services bundle:
In this case, we are going to go over the LookupRecord controller (SQLRecordLookupService).
We are going to use PostgreSQL for the backend data store and the MovieLens data.
ml-latest.zip
filemovielens
movielens
:create table movies (
movie_id int,
title varchar(200),
genres varchar(1000),
primary key(movie_id)
);
create table ratings (
user_id int,
movie_id int,
rating float,
timestamp bigint,
primary key(user_id, movie_id)
);
create table tags (
user_id int,
movie_id int,
tag varchar(255),
timestamp bigint,
primary key(user_id, movie_id, tag)
);
create table links (
movie_id int,
imdb_id int,
tmdb_id int,
primary key(movie_id)
);
create table genome_tags (
tag_id int,
tag varchar(100),
primary key(tag_id)
);
create table genome_scores (
movie_id int,
tag_id int,
relevance float,
primary key(movie_id, tag_id)
);
movielens=# \copy movies from './ml-latest/movies.csv' delimiter ',' CSV header;
movielens=# \copy ratings from './ml-latest/ratings.csv' delimiter ',' CSV header;
movielens=# \copy tags from './ml-latest/tags.csv' delimiter ',' CSV header;
movielens=# \copy links from './ml-latest/links.csv' delimiter ',' CSV header;
movielens=# \copy genome_tags from './ml-latest/genome-tags.csv' delimiter ',' CSV header;
movielens=# \copy genome_scores from './ml-latest/genome-scores.csv' delimiter ',' CSV header;