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.sqladaptive_accounts_source.sqladaptive_attributes_source.sqladaptive_dimensions_source.sqladaptive_versions_source.sqlbamboohr_compensation_source.sqlbamboohr_currency_conversion_source.sqlbamboohr_custom_bonus_source.sqlbamboohr_directory_source.sqlbamboohr_emergency_contacts_source.sqlbamboohr_employment_status_source.sqlbamboohr_engineering_division.sqlbamboohr_id_employee_number_mapping_source.sqlbamboohr_job_info_source.sqlbamboohr_metafields_source.sqlbamboohr_ote_source.sqlcategories_yaml_acquisitions_source.sqlcategories_yaml_source.sqlclari_net_arr_entries_source.sqlclari_net_arr_fields_source.sqlclari_net_arr_time_frames_source.sqlclari_net_arr_time_periods_source.sqlclari_net_arr_users_source.sqlconsolidated_page_views.sqlcreate_pi_source_table.sqldaily_engaged_users.sqlengineering_blocking_time_source.sqlengineering_commit_stats.sqlengineering_development_team_members.sqlengineering_layout_shift_source.sqlengineering_lcp_source.sqlengineering_red_master_stats.sqlfct_behavior_structured_event_service_ping_context.sqlfeature_flags_source.sqlflaky_tests_source.sqlgcp_billing_export_credits.sqlgcp_billing_export_project_labels.sqlgcp_billing_export_resource_labels.sqlgcp_billing_export_system_labels.sqlgeozones_yaml_source.sqlgitlab_dotcom_merge_request_assignment_events.sqlgitlab_pto_source.sqllocation_factors_yaml_source.sqlmailgun_events_source.sqlmonthly_stage_usage_by_account.sqlmonthly_stage_usage_by_account_ultimate.sqlnamespace_segmentation_scores_source.sqlnetsuite_actuals_balance_sheet.sqlpage_view_total_reqs.sqlposts.sqlprep_ping_instance_flattened.sqlprep_subscription_lineage.sqlprep_subscription_lineage_parentage_start.sqlptc_scores_source.sqlpte_scores_source.sqlptpt_scores_source.sqlqualtrics_distribution.sqlqualtrics_mailing_contacts.sqlqualtrics_nps_survey_responses.sqlqualtrics_post_purchase_survey_answers.sqlqualtrics_post_purchase_survey_responses_source.sqlqualtrics_question.sqlqualtrics_survey.sqlrelease_managers_source.sqlretention_reasons_for_retention.sqlretention_zuora_subscription_.sqlroles_yaml_source.sqlsignups.sqlsnowplow_gitlab_events_standard_context.sqlsnowplow_gitlab_events_web_page_id.sqlsnowplow_gitlab_staging_events_web_page_id.sqlsnowplow_performance_timing_metrics.sqlstages_groups_yaml_source.sqlstages_yaml_source.sqlteam_yaml_source.sqlthanos_stage_group_error_budget_availability_source.sqlthanos_stage_group_error_budget_seconds_remaining_source.sqlthanos_stage_group_error_budget_seconds_spent_source.sqlthanos_total_haproxy_bytes_out.sqltime_to_first_response.sqltopics_with_no_response.sqlusage_ping_metrics_source.sqlversion_usage_data_unpacked_stats_used.sqlvisits.sqlwk_usage_ping_geo_node_usage.sqlzendesk_community_relations_ticket_audits_source.sqlzendesk_sla_policies_source.sqlzendesk_ticket_audits_source.sqlzendesk_ticket_custom_field_values_sensitive.sqlzendesk_ticket_custom_fields.sqlzuora_subscription_lineage.sqlzuora_subscription_parentage_start.sql
41 Models with 'inner join'
ripgrep command: rg -UP 'join\n*\s*lateral flatten' -l
bdg_metrics_redis_events.sqldb_structure_merge_requests.sqldbt_model_source.sqldbt_run_results_source.sqldbt_snapshots_results_source.sqldbt_source_freshness_results_source.sqldbt_source_test_results_source.sqldbt_test_results_source.sqldbt_test_source.sqldim_ping_instance.sqldim_team.sqlfct_performance_indicator_targets.sqlgeozones_yaml_flatten_source.sqlgitlab_dotcom_namespace_lineage_scd.sqllocation_factors_yaml_flatten_source.sqlsheetload_google_cloud_ip_ranges_source.sqlsheetload_google_user_ip_ranges_source.sqlsnowplow_gitlab_events_experiment_contexts.sqlversion_usage_stats_list.sqlversion_user_activity_by_stage_monthly_unpacked.sqlwk_dim_company.sqlwk_fct_user_membership.sqlworkday_bonus_source.sqlworkday_compensation_source.sqlworkday_emergency_contacts_source.sqlworkday_employment_status_source.sqlworkday_job_info_source.sqlworkday_on_target_earnings_source.sqlzengrc_assessment_to_assessors.sqlzengrc_assessment_to_audit.sqlzengrc_audit_to_audit_managers.sqlzengrc_control_to_objective.sqlzengrc_issue_to_audit.sqlzengrc_issue_to_control.sqlzengrc_issue_to_program.sqlzengrc_person.sqlzengrc_program.sqlzengrc_request_to_assignees.sqlzengrc_request_to_control.sqlzengrc_request_to_issue.sqlzengrc_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 bysection 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