Keep Your Analytics Lint Free With SQLFluff

The Python Podcast.__init__

Episode | Podcast

Date: Tue, 08 Jun 2021 21:00:00 -0400

<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>The growth of analytics has accelerated the use of SQL as a first class language. It has also grown the amount of collaboration involved in writing and maintaining SQL queries. With collaboration comes the inevitable variation in how queries are written, both structurally and stylistically which can lead to a significant amount of wasted time and energy during code review and employee onboarding. Alan Cruickshank was feeling the pain of this wasted effort first-hand which led him down the path of creating SQLFluff as a linter and formatter to enforce consistency and find bugs in the SQL code that he and his team were working with. In this episode he shares the story of how SQLFluff evolved from a simple hackathon project to an open source linter that is used across a range of companies and fosters a growing community of users and contributors. He explains how it has grown to support multiple dialects of SQL, as well as integrating with projects like DBT to handle templated queries. This is a great conversation about the long detours that are sometimes necessary to reach your original destination and the powerful impact that good tooling can have on team productivity.</p> <h2>Announcements</h2> <ul> <li>Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.</li> <li>When you&#8217;re ready to launch your next app or want to try a project you hear about on the show, you&#8217;ll need somewhere to deploy it, so take a look at our friends over at Linode. With the launch of their managed Kubernetes platform it&#8217;s easy to get started with the next generation of deployment and scaling, powered by the battle tested Linode platform, including simple pricing, node balancers, 40Gbit networking, dedicated CPU and GPU instances, and worldwide data centers. Go to <a href="https://www.pythonpodcast.com/linode?utm_source=rss&amp;utm_medium=rss">pythonpodcast.com/linode</a> and get a $100 credit to try out a Kubernetes cluster of your own. And don&#8217;t forget to thank them for their continued support of this show!</li> <li>We&#8217;ve all been asked to help with an ad-hoc request for data by the sales and marketing team. Then it becomes a critical report that they need updated every week or every day. Then what do you do? Send a CSV via email? Write some Python scripts to automate it? But what about incremental sync, API quotas, error handling, and all of the other details that eat up your time? Today, there is a better way. With Census, just write SQL or plug in your dbt models and start syncing your cloud warehouse to SaaS applications like Salesforce, Marketo, Hubspot, and many more. Go to <a href="https://www.pythonpodcast.com/census?utm_source=rss&amp;utm_medium=rss">pythonpodcast.com/census</a> today to get a free 14-day trial.</li> <li>Your host as usual is Tobias Macey and today I&#8217;m interviewing Alan Cruickshank about SQLFluff, a dialect-flexible and configurable SQL linter</li> </ul> <h2>Interview</h2> <ul> <li>Introductions</li> <li>How did you get introduced to Python?</li> <li>Can you describe what SQLFluff is and the story behind it?</li> <li>SQL is one of the oldest programming languages that is still in regular use. Why do you think that there are so few linters for it?</li> <li>Who are the target users of SQLFluff and how do those personas influence the design and user experience of the project?</li> <li>What are some of the characteristics of SQL and how it is used that contribute to readability/comprehension challenges? <ul> <li>What are some of the additional difficulties that are introduced by templating in the queries?</li> </ul> </li> <li>How is SQLFluff implemented? <ul> <li>How have the goals and design of the project changed since you first began working on it?</li> </ul> </li> <li>How do you handle support of varying SQL dialects without undue maintenance burdens?</li> <li>What are some of the stylistic elements and strategies for making SQL code more maintainable?</li> <li>What are some strategies for making queries self-documenting? <ul> <li>What are some signs that you should document it anyway?</li> </ul> </li> <li>What are some of the kinds of bugs that you are able to identify with SQLFluff?</li> <li>What are some of the resources/references that you relied on for identifying useful linting rules?</li> <li>What are some methods for measuring code quality in SQL?</li> <li>What are the most interesting, innovative, or unexpected ways that you have seen SQLFluff used?</li> <li>What are the most interesting, unexpected, or challenging lessons that you have learned while working on SQLFluff?</li> <li>When is SQLFluff the wrong choice?</li> <li>What do you have planned for the future of SQLFluff?</li> </ul> <h2>Keep In Touch</h2> <ul> <li><a href="https://github.com/alanmcruickshank?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">alanmcruickshank</a> on GitHub</li> <li><a href="http://designingoverload.com/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Website</a></li> <li><a href="https://www.linkedin.com/in/amcruickshank/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">LinkedIn</a></li> </ul> <h2>Picks</h2> <ul> <li>Tobias <ul> <li><a href="https://www.hbo.com/the-nevers?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Nevers</a></li> </ul> </li> <li>Alan <ul> <li><a href="https://amzn.to/3ptQTsJ?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Lost Connections</a>: Uncovering the Real Causes of Depression – and the Unexpected Solutions by Johann Hari (affiliate link)</li> <li><a href="https://amzn.to/3cktIvt?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Wim Hof Method</a> by Wim Hof</li> </ul> </li> </ul> <h2>Closing Announcements</h2> <ul> <li>Thank you for listening! Don&#8217;t forget to check out our other show, the <a href="https://feeds.fireside.fm/pythonpodcast/rss">Data Engineering Podcast</a> for the latest on modern data management.</li> <li>Visit the <a href="https://www.pythonpodcast.com?utm_source=rss&amp;utm_medium=rss">site</a> to subscribe to the show, sign up for the mailing list, and read the show notes.</li> <li>If you&#8217;ve learned something or tried out a project from the show then tell us about it! Email <a href="mailto:hosts@podcastinit.com">hosts@podcastinit.com</a>) with your story.</li> <li>To help other people find the show please leave a review on <a href="https://itunes.apple.com/us/podcast/podcast.-init/id981834425?mt=2&amp;uo=6&amp;at=&amp;ct=&amp;utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">iTunes</a> and tell your friends and co-workers</li> <li>Join the community in the new Zulip chat workspace at <a href="https://www.pythonpodcast.com/chat?utm_source=rss&amp;utm_medium=rss">pythonpodcast.com/chat</a></li> </ul> <h2>Links</h2> <ul> <li><a href="https://www.sqlfluff.com/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">SQLFluff</a></li> <li><a href="https://tails.com/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Tails.com</a></li> <li><a href="https://hypothesis.readthedocs.io/en/latest/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Hypothesis</a> <ul> <li><a href="https://www.pythonpodcast.com/episode-52-hypothesis-with-david-maciver/?utm_source=rss&amp;utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="https://projecteuler.net/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Project Euler</a></li> <li><a href="https://flake8.pycqa.org/en/latest/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Flake8</a> <ul> <li><a href="https://www.pythonpodcast.com/flake8-static-analysis-episode-309/?utm_source=rss&amp;utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="https://black.readthedocs.io/en/stable/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Black</a></li> <li><a href="https://feeds.fireside.fm/pythonpodcast/getdbt.com/">dbt</a> <ul> <li><a href="https://www.dataengineeringpodcast.com/dbt-data-analytics-episode-81/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Data Engineering Podcast Episode</a></li> </ul> </li> <li><a href="https://www.snowflake.com/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Snowflake</a> <ul> <li><a href="https://www.dataengineeringpodcast.com/snowflakedb-cloud-data-warehouse-episode-110/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Data Engineering Podcast Episode</a></li> </ul> </li> <li><a href="https://cloud.google.com/bigquery?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">BigQuery</a></li> <li><a href="https://en.wikipedia.org/wiki/Window_function_(SQL)?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">SQL Window Functions</a></li> <li><a href="https://blog.ansi.org/2018/10/sql-standard-iso-iec-9075-2016-ansi-x3-135/#gref?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">ANSI SQL</a></li> <li><a href="https://www.postgresql.org/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">PostgreSQL</a></li> <li><a href="https://www.microsoft.com/en-us/sql-server/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">MS SQL Server</a></li> <li><a href="https://www.oracle.com/database/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Oracle DB</a></li> <li><a href="https://airflow.apache.org/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Airflow</a></li> <li><a href="https://www.sqltutorial.org/sql-subquery/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">SQL Subquery</a></li> <li><a href="https://www.essentialsql.com/introduction-common-table-expressions-ctes/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Common Table Expression (CTE)</a></li> <li><a href="https://www.freecodecamp.org/news/the-rise-of-the-data-engineer-91be18f1e603/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Rise Of The Data Engineer</a> blog post</li> <li><a href="https://maximebeauchemin.medium.com/the-downfall-of-the-data-engineer-5bfb701e5d6b?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Downfall Of The Data Engineer</a> blog post</li> <li><a href="https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Object-Relational Mapper (ORM)</a></li> <li><a href="https://www.tableau.com/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Tableau</a></li> <li><a href="https://github.com/fishtown-analytics/corp/blob/master/dbt_style_guide.md?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Fishtown Analytics SQL Styleguide</a></li> <li><a href="https://docs.telemetry.mozilla.org/concepts/sql_style.html?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Mozilla SQL Styleguide</a></li> <li><a href="https://www.python.org/dev/peps/pep-0020/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Zen of Python</a></li> <li><a href="https://docs.getdbt.com/docs/building-a-dbt-project/package-management?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">dbt Packages</a></li> <li><a href="https://github.com/google/yapf?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">yapf</a></li> <li><a href="https://en.wikipedia.org/wiki/Set_theory?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Set Theory</a></li> <li><a href="https://github.com/pgjones/flake8-sql?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">Flake8 SQL Plugin</a></li> </ul> <p>The intro and outro music is from Requiem for a Fish <a href="http://freemusicarchive.org/music/The_Freak_Fandango_Orchestra/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">The Freak Fandango Orchestra</a> / <a href="http://creativecommons.org/licenses/by-sa/3.0/?utm_source=rss&amp;utm_medium=rss" rel="noopener" target="_blank">CC BY-SA</a></p> </div> <img alt="" height="0" src="https://analytics.boundlessnotions.com/piwik.php?idsite=1&amp;rec=1&amp;url=https%3A%2F%2Fwww.pythonpodcast.com%2Fsqlfluff-sql-linter-episode-318%2F&amp;action_name=Keep+Your+Analytics+Lint+Free+With+SQLFluff+-+Episode+318&amp;urlref=https%3A%2F%2Fwww.pythonpodcast.com%2Ffeed%2F&amp;utm_source=rss&amp;utm_medium=rss" style="border: 0; width: 0; height: 0;" width="0" />