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

Sqlfluff 3.0.6 with config update #3663

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
65 changes: 31 additions & 34 deletions sql/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ exclude_rules = L011,L014,L015,L016,L020,L022,L026,L027,L028,L029,L030,L031,L032
# L051 - INNER JOIN must be fully qualified. Probably should use this but not our style.
# L060 - Use COALESCE instead of IFNULL or NVL. We think ISNULL is clearer.
# L071 - Turn off until https://github.com/sqlfluff/sqlfluff/issues/4188 is addressed
# The depth to recursively parse to (0 for unlimited)
recurse = 0
# Below controls SQLFluff output, see max_line_length for SQL output
output_line_length = 80

# The maximum line length for SQL output
max_line_length = 80
# Number of passes to run before admitting defeat
runaway_limit = 10
# Ignore errors by category (one or more of the following, separated by commas: lexing,linting,parsing,templating)
Expand Down Expand Up @@ -69,11 +70,14 @@ processes = -1

[sqlfluff:indentation]
# See https://docs.sqlfluff.com/en/stable/indentation.html
tab_space_size = 2
indent_unit = space
indented_joins = False
indented_ctes = False
indented_using_on = False
indented_on_contents = True
template_blocks_indent = True
allow_implicit_indents = True

# Layout configuration
# See https://docs.sqlfluff.com/en/stable/layout.html#configuring-layout-and-spacing
Expand Down Expand Up @@ -134,116 +138,109 @@ apply_dbt_builtins = True

# Some rules can be configured directly from the config common to other rules
[sqlfluff:rules]
tab_space_size = 2
max_line_length = 80
indent_unit = space
allow_scalar = True
single_table_references = consistent
unquoted_identifiers_policy = all

# Some rules have their own specific config.
[sqlfluff:rules:L003]
hanging_indents = True

[sqlfluff:rules:L010]
[sqlfluff:rules:capitalisation.keywords]
# Keywords
capitalisation_policy = upper
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L011]
[sqlfluff:rules:aliasing.table]
# Aliasing preference for tables
aliasing = explicit

[sqlfluff:rules:L012]
[sqlfluff:rules:aliasing.column]
# Aliasing preference for columns
aliasing = explicit

[sqlfluff:rules:L014]
[sqlfluff:rules:capitalisation.identifiers]
# Unquoted identifiers
extended_capitalisation_policy = consistent
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L016]
[sqlfluff:rules:layout.long_lines]
# Line length
ignore_comment_lines = False
ignore_comment_clauses = False

[sqlfluff:rules:L027]
[sqlfluff:rules:references.qualification]
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L026]
[sqlfluff:rules:references.from]
# References must be in FROM clause
# Disabled for some dialects (e.g. bigquery)
force_enable = False

[sqlfluff:rules:L028]
[sqlfluff:rules:references.consistent]
# References must be consistently used
# Disabled for some dialects (e.g. bigquery)
force_enable = False

[sqlfluff:rules:L029]
[sqlfluff:rules:references.keywords]
# Keywords should not be used as identifiers.
unquoted_identifiers_policy = aliases
quoted_identifiers_policy = none
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L030]
[sqlfluff:rules:capitalisation.functions]
# Function names
extended_capitalisation_policy = consistent
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L031]
[sqlfluff:rules:aliasing.forbid]
# Avoid table aliases in from clauses and join conditions.
# Disabled for some dialects (e.g. bigquery)
force_enable = False

[sqlfluff:rules:L036]
[sqlfluff:rules:layout.select_targets]
wildcard_policy = single

[sqlfluff:rules:L038]
[sqlfluff:rules:convention.select_trailing_comma]
# Trailing commas
select_clause_trailing_comma = forbid

[sqlfluff:rules:L040]
[sqlfluff:rules:capitalisation.literals]
# Null & Boolean Literals
capitalisation_policy = consistent
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L042]
[sqlfluff:rules:structure.subquery]
# By default, allow subqueries in from clauses, but not join clauses
forbid_subquery_in = join

[sqlfluff:rules:L047]
[sqlfluff:rules:convention.count_rows]
# Consistent syntax to count all rows
prefer_count_1 = False
prefer_count_0 = True

[sqlfluff:rules:L051]
[sqlfluff:rules:ambiguous.join]
# Fully qualify JOIN clause
fully_qualify_join_types = inner

[sqlfluff:rules:L052]
[sqlfluff:rules:convention.terminator]
# Semi-colon formatting approach
multiline_newline = False
require_final_semicolon = False

[sqlfluff:rules:L054]
[sqlfluff:rules:ambiguous.column_references]
# GROUP BY/ORDER BY column references
group_by_and_order_by_style = consistent

[sqlfluff:rules:L057]
[sqlfluff:rules:references.special_chars]
## Special characters in identifiers
unquoted_identifiers_policy = all
quoted_identifiers_policy = all
Expand All @@ -252,14 +249,14 @@ additional_allowed_characters = "-."
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L059]
[sqlfluff:rules:references.quoting]
# Policy on quoted and unquoted identifiers
prefer_quoted_identifiers = False
ignore_words = None
ignore_words_regex = None
force_enable = False

[sqlfluff:rules:L062]
[sqlfluff:rules:convention.blocked_words]
# Comma separated list of blocked words that should not be used
blocked_words = None
# Regex of blocked SQL that should not be used.
Expand All @@ -272,19 +269,19 @@ blocked_words = None
# Block 2021_06_01 (probably forgot to update month to July for 2021)
blocked_regex = (TABLESAMPLE|sample_data|2022_?05_?12|2022_?06_?09|2022_?07_?01|2021_?06_?01)

[sqlfluff:rules:L063]
[sqlfluff:rules:capitalisation.types]
# Data Types
extended_capitalisation_policy = upper
# Comma separated list of words to ignore for this rule
ignore_words = None
ignore_words_regex = None

[sqlfluff:rules:L064]
[sqlfluff:rules:convention.quoted_literals]
# Consistent usage of preferred quotes for quoted literals
preferred_quoted_literal_style = single_quotes
# Disabled for dialects that do not support single and double quotes for quoted literals (e.g. Postgres)
force_enable = False

[sqlfluff:rules:L066]
[sqlfluff:rules:aliasing.length]
min_alias_length = None
max_alias_length = None
2 changes: 1 addition & 1 deletion sql/2022/accessibility/alt_ending_in_image_extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SELECT
# Given a random alt, how often will it end in a file extension
total_alts_with_file_extensions / total_non_empty_alts AS pct_alts_with_file_extension,

extension_stat.extension AS extension,
extension_stat.extension,
COUNT(0) AS total_sites_using,
# Of sites with a non-empty alt, what % have an alt with this file extension
COUNT(0) / sites_with_non_empty_alt AS pct_applicable_sites_using,
Expand Down
6 changes: 4 additions & 2 deletions sql/2022/accessibility/focus_outline_0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ FROM (
date = '2022-07-01'
GROUP BY
client,
page)
page
)
JOIN (
SELECT
_TABLE_SUFFIX AS client,
COUNT(0) AS total_pages
FROM
`httparchive.summary_pages.2022_07_01_*` -- noqa: L062
GROUP BY
_TABLE_SUFFIX)
_TABLE_SUFFIX
)
USING (client)
GROUP BY
client
3 changes: 2 additions & 1 deletion sql/2022/accessibility/focus_visible.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ FROM (
LENGTH(css) < 0.1 * 1024 * 1024
GROUP BY
client,
page)
page
)
GROUP BY
client
2 changes: 1 addition & 1 deletion sql/2022/accessibility/lighthouse_a11y_audits.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ return results;

SELECT
_TABLE_SUFFIX AS client,
audits.id AS id,
audits.id,
COUNTIF(audits.score > 0) AS num_pages,
COUNT(0) AS total,
COUNTIF(audits.score IS NOT NULL) AS total_applicable,
Expand Down
12 changes: 8 additions & 4 deletions sql/2022/accessibility/lighthouse_a11y_score.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ FROM (
SELECT
CAST(JSON_EXTRACT(report, '$.categories.accessibility.score') AS NUMERIC) AS score
FROM
`httparchive.lighthouse.2019_07_01_mobile`),
`httparchive.lighthouse.2019_07_01_mobile`
),
UNNEST([10, 25, 50, 75, 90]) AS percentile
GROUP BY
date,
Expand All @@ -27,7 +28,8 @@ FROM (
SELECT
CAST(JSON_EXTRACT(report, '$.categories.accessibility.score') AS NUMERIC) AS score
FROM
`httparchive.lighthouse.2020_08_01_mobile`),
`httparchive.lighthouse.2020_08_01_mobile`
),
UNNEST([10, 25, 50, 75, 90]) AS percentile
GROUP BY
date,
Expand All @@ -44,7 +46,8 @@ FROM (
SELECT
CAST(JSON_EXTRACT(report, '$.categories.accessibility.score') AS NUMERIC) AS score
FROM
`httparchive.lighthouse.2021_07_01_mobile`),
`httparchive.lighthouse.2021_07_01_mobile`
),
UNNEST([10, 25, 50, 75, 90]) AS percentile
GROUP BY
date,
Expand All @@ -62,7 +65,8 @@ FROM (
_TABLE_SUFFIX AS client,
CAST(JSON_EXTRACT(report, '$.categories.accessibility.score') AS NUMERIC) AS score
FROM
`httparchive.lighthouse.2022_06_01_*`),
`httparchive.lighthouse.2022_06_01_*`
),
UNNEST([10, 25, 50, 75, 90]) AS percentile
GROUP BY
client,
Expand Down
6 changes: 4 additions & 2 deletions sql/2022/accessibility/media_query_features.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ FROM (
UNNEST(getMediaQueryFeatures(css)) AS feature
WHERE
date = '2022-07-01' AND
feature IS NOT NULL)
feature IS NOT NULL
)
JOIN (
SELECT
_TABLE_SUFFIX AS client,
COUNT(0) AS total
FROM
`httparchive.summary_pages.2022_07_01_*` -- noqa: L062
GROUP BY
client)
client
)
USING
(client)
GROUP BY
Expand Down
12 changes: 6 additions & 6 deletions sql/2022/accessibility/sites_using_role.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ SELECT
percentile,
APPROX_QUANTILES(total_role_attributes, 1000)[OFFSET(percentile * 10)] AS total_role_usages
FROM (
SELECT
_TABLE_SUFFIX AS client,
CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.nodes_using_role.total') AS INT64) AS total_role_attributes
FROM
`httparchive.pages.2022_06_01_*`
),
SELECT
_TABLE_SUFFIX AS client,
CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.nodes_using_role.total') AS INT64) AS total_role_attributes
FROM
`httparchive.pages.2022_06_01_*`
),
UNNEST([10, 25, 50, 75, 90, 100]) AS percentile
GROUP BY
percentile,
Expand Down
6 changes: 4 additions & 2 deletions sql/2022/accessibility/units_properties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ FROM (
WHERE
date = '2022-07-01' AND
# Limit the size of the CSS to avoid OOM crashes.
LENGTH(css) < 0.1 * 1024 * 1024)
LENGTH(css) < 0.1 * 1024 * 1024
)
GROUP BY
client,
unit,
property)
property
)
WHERE
total >= 1000 AND
pct >= 0.01
Expand Down
3 changes: 2 additions & 1 deletion sql/2022/accessibility/valid_html_lang.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FROM (
JSON_EXTRACT_SCALAR(report, "$.audits['html-has-lang'].score") = '1' AS has_lang,
JSON_EXTRACT_SCALAR(report, "$.audits['html-lang-valid'].score") = '1' AS valid_lang
FROM
`httparchive.lighthouse.2022_06_01_*`)
`httparchive.lighthouse.2022_06_01_*`
)
GROUP BY
client
ORDER BY
Expand Down
6 changes: 4 additions & 2 deletions sql/2022/caching/cache_control_directives_invalid.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ FROM (
UNNEST(REGEXP_EXTRACT_ALL(LOWER(resp_cache_control), r'([a-z][^,\s="\']*)')) AS directive_name
GROUP BY
client,
directive_name)
directive_name
)
WHERE
directive_name NOT IN (
'max-age', 'public', 'no-cache', 'must-revalidate', 'no-store',
'private', 'proxy-revalidate', 's-maxage', 'no-transform',
'immutable', 'stale-while-revalidate', 'stale-if-error',
'pre-check', 'post-check')
'pre-check', 'post-check'
)
ORDER BY
client,
directive_occurrences DESC
3 changes: 2 additions & 1 deletion sql/2022/caching/cache_ttl_and_content_age_diff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ FROM (
`httparchive.summary_requests.2022_06_01_*`
WHERE
resp_last_modified != '' AND
expAge > 0),
expAge > 0
),
UNNEST([10, 25, 50, 75, 90]) AS percentile
GROUP BY
client,
Expand Down
3 changes: 2 additions & 1 deletion sql/2022/caching/content_age_older_than_ttl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ FROM (
`httparchive.summary_requests.2022_06_01_*`
WHERE
resp_last_modified != '' AND
expAge > 0)
expAge > 0
)
GROUP BY
client
ORDER BY
Expand Down
Loading