Skip to content

Commit

Permalink
fix: reconcile sqlfluff rules
Browse files Browse the repository at this point in the history
* Merging the sqlfluff config from pyproject.toml into .sqlfluff
  • Loading branch information
ryscheng committed May 3, 2024
1 parent de875e3 commit 723c827
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
15 changes: 12 additions & 3 deletions .sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dialect = bigquery
templater = dbt
runaway_limit = 10
max_line_length = 80
indent_unit = space

[sqlfluff:indentation]
tab_space_size = 4
indent_unit = space
tab_space_size = 2

[sqlfluff:layout:type:comma]
spacing_before = touch
Expand Down Expand Up @@ -35,4 +35,13 @@ capitalisation_policy = lower

[sqlfluff:rules:ambiguous.column_references] # Number in group by
group_by_and_order_by_style = consistent
#group_by_and_order_by_style = explicit
#group_by_and_order_by_style = explicit

[sqlfluff.templater.jinja]
load_macros_from_path = "warehouse/dbt/macros/"
apply_dbt_builtins = true
library_path = "warehouse/common/dbtlintmock"

[sqlfluff.templater.dbt]
project_dir = "."
target = "playground"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dev:frontend": "turbo run dev --filter=@opensource-observer/frontend --parallel",
"format:staged": "lint-staged",
"lint": "turbo run lint --concurrency=100%",
"lint:sql": "poetry run sqlfluff lint",
"serve": "yarn serve build",
"test": "turbo run test --concurrency=1",
"test:integration": "(docker compose -f docker/compose.yaml down || true) && docker compose -f docker/compose.yaml run --rm test",
Expand Down
20 changes: 0 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ lz4 = "^4.3.3"
arrow = "^1.3.0"
polars = "^0.20.23"


[tool.poetry.scripts]
bq2cloudsql = 'bq2cloudsql.script:run'
oso_lets_go = 'oso_lets_go.wizard:run'
Expand All @@ -55,24 +54,5 @@ dagster-webserver = "^1.7.2"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.sqlfluff]
max_line_length = 80

[tool.sqlfluff.core]
templater = "dbt"

[tool.sqlfluff.indentation]
indent_unit = "space"
tab_space_size = 2

[tool.sqlfluff.templater.jinja]
load_macros_from_path = "warehouse/dbt/macros/"
apply_dbt_builtins = true
library_path = "warehouse/common/dbtlintmock"

[tool.sqlfluff.templater.dbt]
project_dir = "."
target = "playground"

[tool.dagster]
module_name = "oso_dagster.definitions"
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ all_npm as (
LOWER(JSON_VALUE(npm.url)) like 'https://npmjs.com/package/%'
then SUBSTR(LOWER(JSON_VALUE(npm.url)), 28)
when
LOWER(JSON_VALUE(npm.url)) like 'https://www.npmjs.com/package/%'
LOWER(
JSON_VALUE(npm.url)
) like 'https://www.npmjs.com/package/%'
then SUBSTR(LOWER(JSON_VALUE(npm.url)), 31)
end as artifact_name,
LOWER(JSON_VALUE(npm.url)) as artifact_url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ where
and receipt_status = 1
and receipt_contract_address is not null
{% if is_incremental() %}
AND block_timestamp >= (
SELECT MAX(block_timestamp)
FROM {{ this }}
)
AND block_timestamp < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)
{% endif %}
AND block_timestamp >= (
SELECT MAX(block_timestamp)
FROM {{ this }}
)
AND block_timestamp < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)
{% endif %}
23 changes: 12 additions & 11 deletions warehouse/dbt/models/staging/github/stg_github__events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@ where

{# If this is production then make sure it's incremental #}
{% if target.name == 'production' %}
{% if is_incremental() %}
AND _TABLE_SUFFIX > FORMAT_TIMESTAMP("%y%m%d", TIMESTAMP_SUB(_dbt_max_partition, INTERVAL 1 DAY))
{% else %}
{#
If/when we do full refreshes we are currently only taking data from 2015
onward due to schema changes of the github events in the githubarchive
#}
AND _TABLE_SUFFIX >= "150101"
{% endif %}
{% elif target.name in ['dev', 'playground'] %}
{% if is_incremental() %}
AND _TABLE_SUFFIX > FORMAT_TIMESTAMP("%y%m%d", TIMESTAMP_SUB(_dbt_max_partition, INTERVAL 1 DAY))
{% else %}
{#
If/when we do full refreshes we are currently only taking data from 2015
onward due to schema changes of the github events in the githubarchive
#}
AND _TABLE_SUFFIX >= "150101"
{% endif %}
{% elif target.name in ['dev', 'playground'] %}
{#
If this is not production then we only copy the most recent number of days
(default to 14)
#}
and created_at
>= TIMESTAMP_SUB(
CURRENT_TIMESTAMP(), interval {{ env_var("PLAYGROUND_DAYS", '14') }} day
CURRENT_TIMESTAMP(),
interval {{ env_var("PLAYGROUND_DAYS", '14') }} day
)
{% endif %}

0 comments on commit 723c827

Please sign in to comment.