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

H-3304: Initial setup for SqlFluff #5781

Merged
merged 8 commits into from
Dec 3, 2024

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

We don't have an SQL formatter and SqlFluff seems the best suited one out there. This adds a basic setup to the CI and a simple configuration.

❓ How to test this?

  • Install the linter using brew install sqlfluff
  • Run it with sqlfluff fix

Adding it to Zed as autoformatter:

Merge this snippet into your configuration:

  "languages": {
    "SQL": {
      "formatter": [
        {
          "external": {
            "command": "sqlfluff",
            "arguments": ["fix", "-"]
          }
        }
      ]
    }
  }

@TimDiekmann TimDiekmann self-assigned this Dec 3, 2024
@TimDiekmann TimDiekmann changed the title H-3304: Initial setup for SqlFluff H-3304: Initial setup for SqlFluff Dec 3, 2024
@github-actions github-actions bot added area/infra Relates to version control, CI, CD or IaC (area) area/infra > docker area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team labels Dec 3, 2024
.sqlfluff Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 23.07%. Comparing base (863d181) to head (a112102).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5781      +/-   ##
==========================================
- Coverage   23.12%   23.07%   -0.05%     
==========================================
  Files         561      568       +7     
  Lines       18913    19103     +190     
  Branches     2680     2697      +17     
==========================================
+ Hits         4373     4408      +35     
- Misses      14488    14643     +155     
  Partials       52       52              
Flag Coverage Ξ”
apps.hash-ai-worker-ts 1.32% <ΓΈ> (ΓΈ)
apps.hash-api 1.16% <ΓΈ> (ΓΈ)
blockprotocol.type-system 46.42% <ΓΈ> (ΓΈ)
local.harpc-client 65.18% <ΓΈ> (-6.85%) ⬇️
local.hash-backend-utils 8.80% <ΓΈ> (ΓΈ)
local.hash-graph-sdk 100.00% <ΓΈ> (ΓΈ)
local.hash-isomorphic-utils 1.03% <ΓΈ> (ΓΈ)
local.hash-subgraph 24.54% <ΓΈ> (ΓΈ)
rust.deer 6.66% <ΓΈ> (ΓΈ)
rust.error-stack 72.51% <ΓΈ> (ΓΈ)
rust.sarif 87.66% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 3, 2024

Benchmark results

@rust/hash-graph-benches – Integrations

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.9 \mathrm{ms} \pm 227 \mathrm{ΞΌs}\left({\color{lightgreen}-29.524 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.8 \mathrm{ms} \pm 239 \mathrm{ΞΌs}\left({\color{gray}-0.340 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$17.2 \mathrm{ms} \pm 221 \mathrm{ΞΌs}\left({\color{gray}-0.887 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$17.9 \mathrm{ms} \pm 249 \mathrm{ΞΌs}\left({\color{gray}0.561 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.7 \mathrm{ms} \pm 195 \mathrm{ΞΌs}\left({\color{gray}-1.503 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$17.3 \mathrm{ms} \pm 228 \mathrm{ΞΌs}\left({\color{red}5.61 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$17.1 \mathrm{ms} \pm 220 \mathrm{ΞΌs}\left({\color{gray}1.79 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$17.0 \mathrm{ms} \pm 233 \mathrm{ΞΌs}\left({\color{lightgreen}-19.572 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$18.0 \mathrm{ms} \pm 235 \mathrm{ΞΌs}\left({\color{red}5.04 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$67.4 \mathrm{ms} \pm 269 \mathrm{ΞΌs}\left({\color{gray}0.929 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$39.9 \mathrm{ms} \pm 278 \mathrm{ΞΌs}\left({\color{gray}2.58 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$58.1 \mathrm{ms} \pm 301 \mathrm{ΞΌs}\left({\color{gray}-0.163 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$44.4 \mathrm{ms} \pm 305 \mathrm{ΞΌs}\left({\color{gray}2.20 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$49.6 \mathrm{ms} \pm 335 \mathrm{ΞΌs}\left({\color{gray}0.497 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$54.5 \mathrm{ms} \pm 337 \mathrm{ΞΌs}\left({\color{gray}0.795 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$111 \mathrm{ms} \pm 565 \mathrm{ΞΌs}\left({\color{gray}2.16 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$44.0 \mathrm{ms} \pm 272 \mathrm{ΞΌs}\left({\color{gray}0.959 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$103 \mathrm{ms} \pm 799 \mathrm{ΞΌs}\left({\color{gray}2.46 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$84.2 \mathrm{ms} \pm 522 \mathrm{ΞΌs}\left({\color{gray}0.461 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$93.1 \mathrm{ms} \pm 371 \mathrm{ΞΌs}\left({\color{gray}0.733 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$98.7 \mathrm{ms} \pm 472 \mathrm{ΞΌs}\left({\color{gray}2.74 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.40 \mathrm{ms} \pm 7.56 \mathrm{ΞΌs}\left({\color{gray}2.14 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$267 \mathrm{ms} \pm 1.11 \mathrm{ms}\left({\color{gray}-0.727 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$26.6 \mathrm{ms} \pm 374 \mathrm{ΞΌs}\left({\color{gray}0.639 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$20.0 \mathrm{ms} \pm 137 \mathrm{ΞΌs}\left({\color{gray}0.195 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$52.0 \mathrm{ms} \pm 2.50 \mathrm{ms}\left({\color{red}42.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$176 \mathrm{ms} \pm 1.36 \mathrm{ms}\left({\color{gray}-0.134 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.92 \mathrm{ms} \pm 5.19 \mathrm{ΞΌs}\left({\color{gray}0.264 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.09 \mathrm{ms} \pm 8.52 \mathrm{ΞΌs}\left({\color{gray}0.197 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.93 \mathrm{ms} \pm 6.88 \mathrm{ΞΌs}\left({\color{gray}0.856 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.86 \mathrm{ms} \pm 14.3 \mathrm{ΞΌs}\left({\color{gray}-0.488 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$13.5 \mathrm{ms} \pm 65.9 \mathrm{ΞΌs}\left({\color{gray}-3.060 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$4.06 \mathrm{ms} \pm 30.0 \mathrm{ΞΌs}\left({\color{lightgreen}-19.805 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.94 \mathrm{ms} \pm 9.49 \mathrm{ΞΌs}\left({\color{gray}-0.386 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.92 \mathrm{ms} \pm 6.30 \mathrm{ΞΌs}\left({\color{gray}-1.496 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.15 \mathrm{ms} \pm 12.2 \mathrm{ΞΌs}\left({\color{gray}0.111 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$3.30 \mathrm{ms} \pm 15.1 \mathrm{ΞΌs}\left({\color{red}20.2 \mathrm{\%}}\right) $$ Flame Graph

Copy link
Member

@indietyp indietyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -77,7 +77,7 @@ CREATE TABLE entity_has_left_entity (
FOREIGN KEY (left_web_id, left_entity_uuid) REFERENCES entity_ids
);
CREATE INDEX entity_has_left_entity_source_idx
ON entity_has_left_entity(web_id, entity_uuid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I am a huge fan of the removal of indentation here (or citus one), but no strong opinions really.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this is configurable. I'll take a Quick Look

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found for JOIN but not for creating indices/extensions. Also not a strong opinion, so I'll just merge it πŸ™‚

@TimDiekmann TimDiekmann added this pull request to the merge queue Dec 3, 2024
Merged via the queue into main with commit ecce2fd Dec 3, 2024
166 checks passed
@TimDiekmann TimDiekmann deleted the t/h-3304-use-sqlfluff-as-sql-formatterlinter branch December 3, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/infra > docker area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

2 participants