%sql
CREATE SCHEMA IF NOT EXISTS amazon_reviews;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
%sql
DESCRIBE SCHEMA EXTENDED amazon_reviews;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
database_description_itemdatabase_description_value
Catalog Namehive_metastore
Namespace Nameamazon_reviews
Comment
Locationdbfs:/user/hive/warehouse/amazon_reviews.db
Ownerroot
Properties
%sql
USE amazon_reviews;
CREATE OR REPLACE TEMPORARY VIEW temp_table USING csv
OPTIONS(PATH = 's3://reviews-amazon/Data_source/amazon_reviews.csv',
header = "true",
mode= "PERMISSIVE"
);

CREATE OR REPLACE TABLE reviews AS 
SELECT * FROM temp_table;

SELECT * FROM reviews LIMIT 10;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
id0nameasinsbrandcategorieskeysmanufacturerdatedateAddeddateSeendidPurchasedoRecommendid12numHelpfulratingsourceURLstexttitleuserCityuserProvinceusername
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-13T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=166This product so far has not disappointed. My children love to use it and I like the ability to monitor control what content they see with ease.KindlenullnullAdapter
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-13T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167great for beginner or experienced person. Bought as a gift and she loves itvery fastnullnulltruman
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-13T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167Inexpensive tablet for him to use and learn on, step up from the NABI. He was thrilled with it, learn how to Skype on it already...Beginner tablet for our 9 year old son.nullnullDaveZ
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-13T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull04http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167I've had my Fire HD 8 two weeks now and I love it. This tablet is a great value.We are Prime Members and that is where this tablet SHINES. I love being able to easily access all of the Prime content as well as movies you can download and watch laterThis has a 1280/800 screen which has some really nice look to it its nice and crisp and very bright infact it is brighter then the ipad pro costing $900 base model. The build on this fire is INSANELY AWESOME running at only 7.7mm thick and the smooth glossy feel on the back it is really amazing to hold its like the futuristic tab in ur hands.Good!!!nullnullShacks
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-12T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167I bought this for my grand daughter when she comes over to visit. I set it up with her as the user, entered her age and name and now Amazon makes sure that she only accesses sites and content that are appropriate to her age. Simple to do and she loves the capabilities. I also bought and installed a 64gig SD card which gives this little tablet plenty of storage. For the price I think this tablet is best one out there. You can spend hundreds of dollars more for additional speed and capacity but when it comes to the basics this tablets does everything that most people will ever need at a fraction of the cost.Fantastic Tablet for kidsnullnullexplore42
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-12T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167This amazon fire 8 inch tablet is the perfect size. I purchased it for my husband so that he has a bigger screen than just his phone. He had gotten me one a few years ago so I knew it would be a good purchase.Just what we expectednullnulltklit
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-12T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull04http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167Great for e-reading on the go, nice and light weight, and for the price point given, definitely worth the purchase.great e-reader tabletnullnullDroi
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-12T00:00:00.000Z2017-07-03T23:33:15Z2017-06-07T09:04:00.000Z,2017-04-30T00:45:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=200,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=167I gave this as a Christmas gift to my inlaws, husband and uncle. They loved it and how easy they are to use with fantastic features!Great for giftsnullnullKacy
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-23T00:00:00.000Z2017-07-03T23:28:24Z2017-06-07T09:04:00.000Z,2017-04-30T00:44:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=154,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=120Great as a device to read books. I like that it links with my borrowed library e-books. Switched from another popular tablet brand and I am happy with the choice I made. It took some time to get books from my previous non-Kindle reader, but finally figured out a way!Great for readingnullnullWeebee
AVqkIhwDv8e3D1O-lebbAll-New Fire HD 8 Tablet, 8 HD Display, Wi-Fi, 16 GB - Includes Special Offers, MagentaB01AHB9CN2AmazonElectronics,iPad & Tablets,All Tablets,Fire Tablets,Tablets,Computers & Tablets841667104676,amazon/53004484,amazon/b01ahb9cn2,0841667104676,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/5620406,allnewfirehd8tablet8hddisplaywifi16gbincludesspecialoffersmagenta/b01ahb9cn2Amazon2017-01-23T00:00:00.000Z2017-07-03T23:28:24Z2017-06-07T09:04:00.000Z,2017-04-30T00:44:00.000ZnullTRUEnull05http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=154,http://reviews.bestbuy.com/3545/5620406/reviews.htm?format=embedded&page=121I love ordering books and reading them with the reader.Great and lightweight readernullnullRoboBob
%sql
describe detail reviews;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
formatidnamedescriptionlocationcreatedAtlastModifiedpartitionColumnsclusteringColumnsnumFilessizeInBytespropertiesminReaderVersionminWriterVersiontableFeaturesstatistics
delta9961657c-5a68-4f95-8a9f-9f9a32e30f23hive_metastore.amazon_reviews.reviewsnulldbfs:/user/hive/warehouse/amazon_reviews.db/reviews2023-11-08T04:59:42.974Z2023-11-08T04:59:57ZList()List()44371123Map()25List(appendOnly, changeDataFeed, checkConstraints, columnMapping, generatedColumns, invariants)Map()
%sql
DESCRIBE reviews;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
col_namedata_typecomment
id0stringnull
namestringnull
asinsstringnull
brandstringnull
categoriesstringnull
keysstringnull
manufacturerstringnull
datestringnull
dateAddedstringnull
dateSeenstringnull
didPurchasestringnull
doRecommendstringnull
id12stringnull
numHelpfulstringnull
ratingstringnull
sourceURLsstringnull
textstringnull
titlestringnull
userCitystringnull
userProvincestringnull
usernamestringnull
%sql
SELECT count(*),count(id0),
count(name),
count(asins),
count(brand),
count(categories),
count(keys),
count(manufacturer),
count(date),
count(dateAdded),
count(dateSeen),
count(didPurchase),
count(doRecommend),
count(id12),
count(numHelpful),
count(rating),
count(sourceURLs),
count(text),
count(title),
count(userCity),
count(userProvince),
count(username) FROM reviews
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
count(1)count(id0)count(name)count(asins)count(brand)count(categories)count(keys)count(manufacturer)count(date)count(dateAdded)count(dateSeen)count(didPurchase)count(doRecommend)count(id12)count(numHelpful)count(rating)count(sourceURLs)count(text)count(title)count(userCity)count(userProvince)count(username)
41421414212804628029346453453234532346603462830751346449603425371933795285933394434441339527057694128597

Creating Table which represents Gold data

%sql
create table reviews_gold as
select * from reviews;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
num_affected_rowsnum_inserted_rows

Removing Non Relevant Columns

%sql
ALTER TABLE reviews_gold
DROP column userCity;
<style scoped> .ansiout { display: block; unicode-bidi: embed; white-space: pre-wrap; word-wrap: break-word; word-break: break-all; font-family: "Menlo", "Monaco", "Consolas", "Ubuntu Mono", "Source Code Pro", monospace; font-size: 13px; color: #555; margin-left: 4px; line-height: 19px; } </style>

com.databricks.backend.common.rpc.SparkDriverExceptions$SQLExecutionException: com.databricks.sql.transaction.tahoe.DeltaAnalysisException: DROP COLUMN is not supported for your Delta table. Please enable Column Mapping on your Delta table with mapping mode 'name'. You can use one of the following commands.

If your table is already on the required protocol version: ALTER TABLE table_name SET TBLPROPERTIES ('delta.columnMapping.mode' = 'name')

If your table is not on the required protocol version and requires a protocol upgrade: ALTER TABLE table_name SET TBLPROPERTIES ( 'delta.columnMapping.mode' = 'name', 'delta.minReaderVersion' = '2', 'delta.minWriterVersion' = '5') Refer to table versioning at https://docs.databricks.com/delta/versioning.html

%sql
ALTER TABLE reviews_gold SET TBLPROPERTIES (
   'delta.columnMapping.mode' = 'name',
   'delta.minReaderVersion' = '2',
   'delta.minWriterVersion' = '5');
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
%sql
ALTER TABLE reviews_gold
DROP COLUMN userCity;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
%sql
ALTER TABLE reviews_gold
DROP COLUMN userProvince;
ALTER TABLE reviews_gold
DROP COLUMN id12;
ALTER TABLE reviews_gold
DROP COLUMN didPurchase;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
%sql
describe reviews_gold
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
col_namedata_typecomment
id0stringnull
namestringnull
asinsstringnull
brandstringnull
categoriesstringnull
keysstringnull
manufacturerstringnull
datestringnull
dateAddedstringnull
dateSeenstringnull
doRecommendstringnull
numHelpfulstringnull
ratingstringnull
sourceURLsstringnull
textstringnull
titlestringnull
usernamestringnull

Removing Null Values

%sql
delete from reviews_gold where text is null;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
num_affected_rows
6980
%sql
select count(*) from reviews_gold
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
count(1)
34441

Deduplication

%sql
select count(*) from 
(select distinct * from reviews_gold) t;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
count(1)
32476
%sql
CREATE OR REPLACE TABLE reviews_gold as
SELECT DISTINCT * FROM reviews_gold;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
num_affected_rowsnum_inserted_rows
%sql
SELECT count(*) FROM reviews_gold;
<style scoped> .table-result-container { max-height: 300px; overflow: auto; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } th { text-align: left; } </style>
count(1)
32476