Skip to content

Instantly share code, notes, and snippets.

@kzzzr
Created August 25, 2020 08:50
Show Gist options
  • Save kzzzr/4e4509976d7c83e2e5d25c88aab06e73 to your computer and use it in GitHub Desktop.
Save kzzzr/4e4509976d7c83e2e5d25c88aab06e73 to your computer and use it in GitHub Desktop.
HIVE - Kiva loans homework
drop table kiva_loans ;
create external table kiva_loans
(
id INT
, funded_amount FLOAT
, loan_amount FLOAT
, activity STRING
, sector STRING
, use STRING
, country_code STRING
, country STRING
, region STRING
, currency STRING
, partner_id STRING
, posted_time STRING
, disbursed_time STRING
, funded_time STRING
, term_in_months FLOAT
, lender_count INT
, tags STRING
, borrower_genders STRING
, repayment_interval STRING
, dt DATE
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "\"")
LOCATION '/user/hive/warehouse/kiva_loans/'
tblproperties ("skip.header.line.count"="1");
select * from kiva_loans limit 10 ;
select count(1), count(dt) from kiva_loans ;
drop table kiva_mpi_region_locations ;
create external table kiva_mpi_region_locations
(
LocationName STRING
, ISO STRING
, country STRING
, region STRING
, world_region STRING
, MPI FLOAT
, geo STRING
, lat FLOAT
, lon FLOAT
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "\"")
LOCATION '/user/hive/warehouse/kiva_mpi_region_locations/'
tblproperties ("skip.header.line.count"="1");
select * from kiva_mpi_region_locations limit 10 ;
select count(1), count(dt) from kiva_mpi_region_locations ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment