Skip to content

Instantly share code, notes, and snippets.

@vinodnerella
Last active June 19, 2018 08:42
Show Gist options
  • Save vinodnerella/0bbf9537af4082b8bfb283be80d0d55b to your computer and use it in GitHub Desktop.
Save vinodnerella/0bbf9537af4082b8bfb283be80d0d55b to your computer and use it in GitHub Desktop.
how to use apache phonenix on Itversity Labs
Using Apache Phoenix on labs:
export PHOENIX_HOME=/usr/hdp/2.5.0.0-1245/phoenix/
export PATH=$PATH:$PHOENIX_HOME/bin
# Save the files us_population.sql, us_populatipn.csv and us_population_queries.sql with the below information
us_population.sql
CREATE TABLE IF NOT EXISTS us_population (
state CHAR(2) NOT NULL,
city VARCHAR NOT NULL,
population BIGINT
CONSTRAINT my_pk PRIMARY KEY (state, city));
us_population.csv
NY,New York,8143197
CA,Los Angeles,3844829
IL,Chicago,2842518
TX,Houston,2016582
PA,Philadelphia,1463281
AZ,Phoenix,1461575
TX,San Antonio,1256509
CA,San Diego,1255540
TX,Dallas,1213825
CA,San Jose,912332
us_population_queries.sql
SELECT state as "State",count(city) as "City Count",sum(population) as "Population Sum"
FROM us_population
GROUP BY state
ORDER BY sum(population) DESC;
export PHOENIX_HOME=/usr/hdp/2.5.0.0-1245/phoenix/
export PATH=$PATH:$PHOENIX_HOME/bin
psql.py nn01.itversity.com:2181 us_population.sql us_population.csv us_population_queries.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment