33. Replace Keywords in Social Media Post Text
Beginner Mode
Scenario
You work for a social media analytics company and have been given a table containing information about social media posts across multiple platforms.
Task
Write a Snowflake SQL query that:
- Selects all columns from
{{ ref("social_media") }} - Replaces every occurrence of
"Python"in thetextcolumn with"PySpark" - Returns the same 7 columns as the input (preserving the original column names)
Schema
social_media
| Column | Type | Description |
|---|---|---|
| id | Integer | Unique identifier for each post |
| text | String | Text content of the social media post |
| date | String | Date the post was made (YYYY-MM-DD format) |
| likes | Integer | Number of likes the post received |
| comments | Integer | Number of comments the post received |
| shares | Integer | Number of shares the post received |
| platform | String | Platform where the post was made (e.g. Twitter, Facebook, Instagram) |
Example
social_media:
| id | text | date | likes | comments | shares | platform |
|---|---|---|---|---|---|---|
| 1 | This is a Python post. | 2022-03-01 | 10 | 3 | 2 | |
| 2 | Another post about Python. | 2022-03-02 | 20 | 5 | 3 | |
| 3 | Python is great for data analysis. | 2022-03-03 | 30 | 2 | 4 |
Expected Output:
| id | text | date | likes | comments | shares | platform |
|---|---|---|---|---|---|---|
| 1 | This is a PySpark post. | 2022-03-01 | 10 | 3 | 2 | |
| 2 | Another post about PySpark. | 2022-03-02 | 20 | 5 | 3 | |
| 3 | PySpark is great for data analysis. | 2022-03-03 | 30 | 2 | 4 |
Note: Every occurrence of "Python" in the text column is replaced with "PySpark". All other columns remain unchanged.
Code Environment
Sign in or try as guest to run your code.
Essential
SQL 0/33
Git 0/15
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
PayPal
TCS
X
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
Uber
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
BMW
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Capital One
Splunk
Intel
SAP
Tesla
GitHub
JaneStreet
Bloomberg
Salesforce
Elastic
CGI
UBS
GitLab
Ubisoft
Slack
Nintendo
EY
Kayak
Lyft
Airbnb
Walmart
Revolut
Visa
Okta
HashiCorp
Instacart
Mastercard