address lateral flatten in the sql style guide
Why is this change being made?
Purpose
Should we use 'inner join' to preface lateral flatten
?
Ultimately, what matters is we establish a guideline specifically for 'lateral flatten' because the code-base is currently inconsistent.
Background
Currently, the style guide states Prefer explicit join statements.
.
While lateral flatten
is technically a join, i.e:
FROM source
INNER JOIN LATERAL FLATTEN(INPUT => TRY_PARSE_JSON(source.requestors)) requestors
I am proposing that the handbook make Lateral Flatten
an exception to the rule.
If we want to go the other way that's fine too.
Reasons
Reason why i propose to make it an exception to the 'explicit join rule':
- The standardized 'lateral flatten' convention is to exclude the 'inner join', for example here are snowflake docs
- Out of the 133 models we currently have that use 'lateral flatten', 92 models (~70%) don't use 'inner join'. It will be easier to mantain consistency if we stick with what we already have.
Models list
92 Models without 'inner join'
ripgrep
command: rg -UP ',\n*\s*lateral flatten' -l
accepted_solutions.sql
adaptive_accounts_source.sql
adaptive_attributes_source.sql
adaptive_dimensions_source.sql
adaptive_versions_source.sql
bamboohr_compensation_source.sql
bamboohr_currency_conversion_source.sql
bamboohr_custom_bonus_source.sql
bamboohr_directory_source.sql
bamboohr_emergency_contacts_source.sql
bamboohr_employment_status_source.sql
bamboohr_engineering_division.sql
bamboohr_id_employee_number_mapping_source.sql
bamboohr_job_info_source.sql
bamboohr_metafields_source.sql
bamboohr_ote_source.sql
categories_yaml_acquisitions_source.sql
categories_yaml_source.sql
clari_net_arr_entries_source.sql
clari_net_arr_fields_source.sql
clari_net_arr_time_frames_source.sql
clari_net_arr_time_periods_source.sql
clari_net_arr_users_source.sql
consolidated_page_views.sql
create_pi_source_table.sql
daily_engaged_users.sql
engineering_blocking_time_source.sql
engineering_commit_stats.sql
engineering_development_team_members.sql
engineering_layout_shift_source.sql
engineering_lcp_source.sql
engineering_red_master_stats.sql
fct_behavior_structured_event_service_ping_context.sql
feature_flags_source.sql
flaky_tests_source.sql
gcp_billing_export_credits.sql
gcp_billing_export_project_labels.sql
gcp_billing_export_resource_labels.sql
gcp_billing_export_system_labels.sql
geozones_yaml_source.sql
gitlab_dotcom_merge_request_assignment_events.sql
gitlab_pto_source.sql
location_factors_yaml_source.sql
mailgun_events_source.sql
monthly_stage_usage_by_account.sql
monthly_stage_usage_by_account_ultimate.sql
namespace_segmentation_scores_source.sql
netsuite_actuals_balance_sheet.sql
page_view_total_reqs.sql
posts.sql
prep_ping_instance_flattened.sql
prep_subscription_lineage.sql
prep_subscription_lineage_parentage_start.sql
ptc_scores_source.sql
pte_scores_source.sql
ptpt_scores_source.sql
qualtrics_distribution.sql
qualtrics_mailing_contacts.sql
qualtrics_nps_survey_responses.sql
qualtrics_post_purchase_survey_answers.sql
qualtrics_post_purchase_survey_responses_source.sql
qualtrics_question.sql
qualtrics_survey.sql
release_managers_source.sql
retention_reasons_for_retention.sql
retention_zuora_subscription_.sql
roles_yaml_source.sql
signups.sql
snowplow_gitlab_events_standard_context.sql
snowplow_gitlab_events_web_page_id.sql
snowplow_gitlab_staging_events_web_page_id.sql
snowplow_performance_timing_metrics.sql
stages_groups_yaml_source.sql
stages_yaml_source.sql
team_yaml_source.sql
thanos_stage_group_error_budget_availability_source.sql
thanos_stage_group_error_budget_seconds_remaining_source.sql
thanos_stage_group_error_budget_seconds_spent_source.sql
thanos_total_haproxy_bytes_out.sql
time_to_first_response.sql
topics_with_no_response.sql
usage_ping_metrics_source.sql
version_usage_data_unpacked_stats_used.sql
visits.sql
wk_usage_ping_geo_node_usage.sql
zendesk_community_relations_ticket_audits_source.sql
zendesk_sla_policies_source.sql
zendesk_ticket_audits_source.sql
zendesk_ticket_custom_field_values_sensitive.sql
zendesk_ticket_custom_fields.sql
zuora_subscription_lineage.sql
zuora_subscription_parentage_start.sql
41 Models with 'inner join'
ripgrep
command: rg -UP 'join\n*\s*lateral flatten' -l
bdg_metrics_redis_events.sql
db_structure_merge_requests.sql
dbt_model_source.sql
dbt_run_results_source.sql
dbt_snapshots_results_source.sql
dbt_source_freshness_results_source.sql
dbt_source_test_results_source.sql
dbt_test_results_source.sql
dbt_test_source.sql
dim_ping_instance.sql
dim_team.sql
fct_performance_indicator_targets.sql
geozones_yaml_flatten_source.sql
gitlab_dotcom_namespace_lineage_scd.sql
location_factors_yaml_flatten_source.sql
sheetload_google_cloud_ip_ranges_source.sql
sheetload_google_user_ip_ranges_source.sql
snowplow_gitlab_events_experiment_contexts.sql
version_usage_stats_list.sql
version_user_activity_by_stage_monthly_unpacked.sql
wk_dim_company.sql
wk_fct_user_membership.sql
workday_bonus_source.sql
workday_compensation_source.sql
workday_emergency_contacts_source.sql
workday_employment_status_source.sql
workday_job_info_source.sql
workday_on_target_earnings_source.sql
zengrc_assessment_to_assessors.sql
zengrc_assessment_to_audit.sql
zengrc_audit_to_audit_managers.sql
zengrc_control_to_objective.sql
zengrc_issue_to_audit.sql
zengrc_issue_to_control.sql
zengrc_issue_to_program.sql
zengrc_person.sql
zengrc_program.sql
zengrc_request_to_assignees.sql
zengrc_request_to_control.sql
zengrc_request_to_issue.sql
zengrc_request_to_requestors.sql
Author Checklist
-
Provided a concise title for this Merge Request (MR) -
Added a description to this MR explaining the reasons for the proposed change, per say why, not just what - Copy/paste the Slack conversation to document it for later, or upload screenshots. Verify that no confidential data is added, and the content is SAFE
-
Assign reviewers for this MR to the correct Directly Responsible Individual/s (DRI) - If the DRI for the page/s being updated isn’t immediately clear, then assign it to one of the people listed in the
Maintained by
section on the page being edited - If your manager does not have merge rights, please ask someone to merge it AFTER it has been approved by your manager in #mr-buddies
- The when to get approval handbook section explains the workflow in more detail
- If the DRI for the page/s being updated isn’t immediately clear, then assign it to one of the people listed in the
-
If the changes affect team members, or warrant an announcement in another way, please consider posting an update in #whats-happening-at-gitlab linking to this MR - If this is a change that directly impacts the majority of global team members, it should be a candidate for #company-fyi. Please work with internal communications and check the handbook for examples.
Edited by Israel Weeks