Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add BQ query for Transformation Queries #607

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tutorial/manipulate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,50 @@ CREATE TABLE "opportunity_denorm" AS
JOIN "tmp_level" ON "user"."Name" = "tmp_level"."Name";
{% endhighlight %}

For BigQuery, the query will look like this:

{% highlight sql %}
WITH tmp_level AS (
SELECT
Name,
CASE
WHEN Levelz = 'S' THEN 'Senior'
WHEN Levelz = 'M' THEN 'Intermediate'
WHEN Levelz = 'J' THEN 'Junior'
END AS Level
FROM
in_c_csv_import.levelx
),
tmp_opportunity AS (
SELECT
* EXCEPT (_timestamp),
CASE
WHEN CAST(Probability as INT64) < 50 THEN 'Poor'
WHEN CAST(Probability as INT64) < 70 THEN 'Good'
ELSE 'Excellent'
END AS ProbabilityClass
FROM
in_c_csv_import.opportunity
)
SELECT
tmp_opportunity.*,
user.Name AS UserName,
user.Sales_Market AS UserSalesMarket,
user.Global_Market AS UserGlobalMarket,
account.Name AS AccountName,
account.Region AS AccountRegion,
account.Status AS AccountStatus,
account.FirstOrder AS AccountFirstOrder
FROM
tmp_opportunity
JOIN
in_c_csv_import.`user` ON tmp_opportunity.OwnerId = user.Id
JOIN
in_c_csv_import.account ON tmp_opportunity.AccountId = account.Id
JOIN
tmp_level ON user.Name = tmp_level.Name;
{% endhighlight %}

Click the **New Code** button. Begin by entering a query name – input *Opportunity denorm*. Next, paste the queries into the editor, and then click **Save**.

{: .image-popup}
Expand Down
Loading