-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Liftingthedata
committed
Jun 29, 2023
1 parent
ba8278b
commit 6878878
Showing
9 changed files
with
75 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ apiVersion: apps/v1 | |
metadata: | ||
name: airflow | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: airflow | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
CREATE OR REPLACE TABLE \`stellarismusv5.twitter_data.bq_tweets\` | ||
{# 1 Table for all tweets #} | ||
CREATE OR REPLACE TABLE `stellarismusv5.twitter_data.bq_tweets` | ||
AS | ||
WITH TweetData AS ( | ||
SELECT * | ||
FROM \`stellarismusv5.twitter_data.tweets-*\` | ||
FROM `stellarismusv5.twitter_data.tweets-*` | ||
) | ||
SELECT * | ||
FROM TweetData; | ||
FROM TweetData; | ||
|
||
{# Hash tag analysis #} | ||
CREATE OR REPLACE TABLE `stellarismusv5.twitter_data.top_hashtags` AS | ||
SELECT | ||
h.item as hashtag, count(*) as frequency | ||
FROM `stellarismusv5.twitter_data.bq_tweets`, UNNEST(Extra_Hashtags.list) as h | ||
group by hashtag | ||
ORDER BY frequency DESC | ||
|
||
|
||
{# User Influence Analysis #} | ||
CREATE OR REPLACE TABLE `stellarismusv5.twitter_data.user_analysis` AS | ||
SELECT | ||
Username, | ||
COUNT(*) AS tweet_count, | ||
SUM(Likes) AS total_likes, | ||
SUM(Retweets) AS total_retweets, | ||
SUM(Followers) AS total_followers | ||
FROM `stellarismusv5.twitter_data.bq_tweets` | ||
GROUP BY Username; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
CREATE OR REPLACE TABLE `stellarismusv5.twitter_data.top_hashtags` AS | ||
SELECT | ||
h.item as hashtag, count(*) as frequency | ||
FROM `stellarismusv5.twitter_data.bq_tweets`, UNNEST(Extra_Hashtags.list) as h | ||
group by hashtag | ||
ORDER BY frequency DESC | ||
|
||
CREATE OR REPLACE TABLE `stellarismusv5.twitter_data.user_analysis` AS | ||
SELECT | ||
User_Id, | ||
COUNT(*) AS tweet_count, | ||
SUM(Likes) AS total_likes, | ||
SUM(Retweets) AS total_retweets, | ||
SUM(Followers) AS total_followers | ||
FROM `stellarismusv5.twitter_data.user_analysis` | ||
GROUP BY User_Id; | ||
|
||
|
||
bq query --nouse_legacy_sql \ | ||
"CREATE OR REPLACE TABLE \`stellarismusv5.twitter_data.top_hashtags\` AS | ||
SELECT | ||
h.item as hashtag, count(*) as frequency | ||
FROM `stellarismusv5.twitter_data.bq_tweets`, UNNEST(Extra_Hashtags.list) as h | ||
group by hashtag | ||
ORDER BY frequency DESC; | ||
; | ||
CREATE OR REPLACE TABLE \`stellarismusv5.twitter_data.user_analysis\` AS | ||
SELECT | ||
Username, | ||
COUNT(*) AS tweet_count, | ||
SUM(Likes) AS total_likes, | ||
SUM(Retweets) AS total_retweets, | ||
SUM(Followers) AS total_followers | ||
FROM \`stellarismusv5.twitter_data.bq_tweets\` | ||
GROUP BY Username; | ||
" |