<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ben Thornton on Medium]]></title>
        <description><![CDATA[Stories by Ben Thornton on Medium]]></description>
        <link>https://medium.com/@bthor10?source=rss-783d06405cc6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bkTHaU0xxfE01JZedR4W0w.jpeg</url>
            <title>Stories by Ben Thornton on Medium</title>
            <link>https://medium.com/@bthor10?source=rss-783d06405cc6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:54:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bthor10/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Engineering Git Workflows: Avoiding Excessive Commits in Pull Requests]]></title>
            <link>https://medium.com/@bthor10/data-engineering-git-workflows-avoiding-excessive-commits-in-pull-requests-28a8dc57fabf?source=rss-783d06405cc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a8dc57fabf</guid>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[commit]]></category>
            <dc:creator><![CDATA[Ben Thornton]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 19:58:16 GMT</pubDate>
            <atom:updated>2023-10-19T21:04:06.388Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article is written to address individual pull requests. Over time a code repository will accumulate hundreds to thousands of commits as the data pipeline evolves.</h4><p>In data engineering, version control systems like Git have become the backbone of high-performance data pipelines. They empower teams to work together seamlessly, track changes, and maintain code quality. However, it’s easy to fall into the trap of making too many commits, especially when working on a feature or bug fix. This can clutter your pull requests, making it challenging for reviewers to see what matters in your branch. Below, we will explore what it means to make concise commits and how they improve pull requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hQjQlZpTSyvniMRk" /><figcaption>Photo by <a href="https://unsplash.com/@yancymin?utm_source=medium&amp;utm_medium=referral">Yancy Min</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Problem With Excessive Commits</h4><p>Imagine you’re working on a new feature for your data pipeline, and you decide to make a Git commit after every minor change or line of code. It may seem like a diligent practice, but it can quickly lead to pull request chaos. Here are two reasons why excessive commits can be problematic:</p><ul><li><strong>Information overload</strong>: With too many commits, your pull request can become inundated with information, making it challenging for reviews to grasp the big picture of your changes. Your branch may include the difference of a single line or adding a thousand lines. Either way, your pull request must clarify what has changed from the main branch.</li><li><strong>Repetitive Code</strong>: Excessive commits often include the same or similar lines of code. This redundancy can be confusing for a reviewer and lead to inefficient feedback. Committing typos in your code can be a direct source of this problem. Before you commit, make sure to do a spell check. There’s nothing more frustrating than creating a data pipeline and realizing your code doesn’t work because a column in your DDL is misspelled.</li></ul><h4>Best Practices for Making Concise Commits</h4><p>To avoid the pitfalls of excess commits and create cleaner, more manageable pull requests, consider the following best practices:</p><ul><li><strong>Seek Feedback Early</strong>: First and most importantly, seek feedback early. If you’re unsure about your approach or changes, don’t hesitate to seek input on your ideas from your team before making the pull request. This will help you catch potential issues and streamline the process.</li><li><strong>Create Feature Branches</strong>: For features or bug fixes, you should always create a separate branch to isolate your work. This way, you can make commits without polluting the main branch’s history.</li><li><strong>Work Incrementally</strong>: Instead of making a commit for every small change, aim to work in batches. Group related changes together into meaningful self-contained commits.</li><li><strong>Commit Messages</strong>: Write clear, concise commit messages describing the changes’ purpose and scope. These messages help reviewers better understand your intentions.</li><li><strong>Interactive Rebase</strong>: Use git rebase -i to “squash” and reorganize your commits before creating a pull request. This will allow you to consolidate multiple commits into one, providing a more straightforward history. This can be a bit complicated to do in the command line, so for further reading on this, I’ve included a link to the <a href="https://docs.github.com/en/get-started/using-git/using-git-rebase-on-the-command-line">Github docs</a>.</li><li><strong>Review Your Changes Locally:</strong> Before pushing to the remote repository or creating a pull request, review your changes locally to ensure you haven’t included unnecessary or repetitive code.</li></ul><h4>Staging Only What Matters</h4><p>Now that we have a general overview of best practices for commits, I want to take a moment to discuss an essential aspect of creating concise commits called “staging.” Git allows you to selectively stage files, helping you avoid unnecessary files in your commits. When ready, stage only relevant files using git add &lt;filename&gt;. For example, if you have changed multiple files but want to commit only one, you can do so with this command. In reverse, to remove a file from the stage, you can use the command git rm &lt;filename&gt;<em> </em>to remove the specific file.</p><h4>When in Doubt, Just Reset</h4><p>Sometimes, despite your best intentions, you might find yourself in a situation where you’ve made incorrect commits or need to undo changes. Two valuable Git commands can come to your rescue: git reset<em> </em>and git reset --Hard origin/&lt;remote branch name&gt;</p><ul><li>git reset: This command is your go-to tool for “uncommitting” changes. It allows you to move the branch to a previous commit while preserving your changes as uncommitted local modifications. For example, if you realize that you’ve made a few unnecessary commits or need rework, you can use git reset to rest the branch and rework your changes.</li><li>git reset --Hard origin/&lt;remote branch name&gt;: This command is a lifesaver when you want to completely discard your local changes and align your branch with the remote branch, typically the development branch. Be cautious when using this command; it is a destructive operation and will discard any uncommitted changes.</li></ul><p>Both of these commands are powerful, but they should be used with care. Always double-check your intentions before executing them to avoid unintended data loss.</p><p>With that said, if you find your own frustration building with using Git and wanting to make a clean pull request, sometimes it is better to start a completely new branch and re-add your changed files. Git is a versatile and flexible tool, and learning to leverage its features effectively will significantly enhance your development experience. Remember that mastering Git takes practice, so be patient with yourself and continually strive for cleaner, more efficient commits.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a8dc57fabf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips and Tricks on Filter Text Data in SQL]]></title>
            <link>https://medium.com/@bthor10/tips-and-tricks-on-filter-text-data-in-sql-207f6f76b38c?source=rss-783d06405cc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/207f6f76b38c</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[text]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Ben Thornton]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 01:05:34 GMT</pubDate>
            <atom:updated>2023-03-06T15:19:48.579Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JdilyCWgPdnurQEQ" /><figcaption>Photo by <a href="https://unsplash.com/@borodinanadi?utm_source=medium&amp;utm_medium=referral">nadi borodina</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Filtering text data in SQL can be a powerful tool for extracting useful information from large datasets. In this article, we will explore various techniques for filtering, including using the WHERE clause and the LIKE operator. Whether you are a seasoned data analyst or just starting out, this article will provide you a couple of great techniques for parsing text data.</p><p>For this article, we’ll be working with a database of grocery store items. The columns include item_name, price, amount, and store_name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*6j8CfXG3SC3qNtBep1qjyg.png" /><figcaption>Grocery item data</figcaption></figure><h4>Upper, Lower, Concatenate</h4><p>For readability purposes, you may want a specific field that is all lower-case or all upper-case. Then, you can apply that formatting to a column by simply using the UPPER() AND LOWER() functions.</p><pre>SELECT <br>    UPPER(item_name) -- or LOWER(item_name)<br>FROM Items</pre><p>If this product data are shown on a website or an app, concatenation will come in handy to combine some columns to create a label such as item_name and price. In the example below, we combine these two fields using CONCAT() function.</p><pre>SELECT<br>    CONCAT(item_name, &#39; - $&#39;, price)<br>FROM Items</pre><p>Using the CONCAT() function, we combine the item_name, a hyphen with a dollar sign, and the price column to create a clear label for a specific item. When we run this query, the result will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*4ejoAs1Q6PH2rJY8rBhshw.png" /><figcaption>Our new item label</figcaption></figure><h4>Basic keyword search</h4><p>If we want to filter our data so that we only see specific items in our table, we can use = (match on a single entity) and IN (for matching on multiple entities) in where-clause like so:</p><pre>-- Using &quot;=&quot;<br>SELECT<br>*<br>FROM Items<br>WHERE <br>    item_name = &#39;Egg&#39;<br><br>-- Using &quot;IN&quot;<br>SELECT<br>*<br>FROM Items<br>WHERE <br>    item_name IN (&#39;Egg&#39;, &#39;Donut&#39;)<br></pre><h4>Making use of the LIKE operator</h4><p>Now we move into techniques that are more tricky to use. For example, in a grocery store inventory database, thousands of item entries are updated multiple times daily. In addition, many new entries are also being made each day due to suppliers delivering new products. So, due to the size of the database and the frequency at which new items are added, knowing every item_name that exists is impossible. But the LIKE operator will be helpful if we need to analyze our inventory. Using it, we can match patterns in data using basic syntax like below:</p><pre>SELECT column_name<br>FROM table<br>WHERE column_name like &#39;pattern&#39;</pre><p>The “pattern” is specified using wildcard characters, such as the percent sign (%) and the underscore (_). The percent sign can represent any number of characters, while the underscore represents a single character. Depending on your goal, wildcards can be placed before or after your pattern. Let’s check out a couple of examples.</p><p>We will pull all items that start with the letter “b.”</p><pre>SELECT<br>*<br>FROM Items<br>WHERE <br>    item_name LIKE &#39;b%&#39;</pre><p>Notice, we place the wildcard after our pattern. As a result, our query returns us with rows in which the item_name starts with “b.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*xcooeeAR3jbuyLEo-_23Qw.png" /></figure><p>Just like we placed the wildcard before our pattern, we can surround the pattern with wildcards on both sides, creating a “contains” statement.</p><pre>SELECT<br>*<br>FROM Items<br>WHERE <br>    item_name LIKE &#39;%ea%&#39;</pre><p>If we want to specify our query even more and only pull back items that meet a certain character count we would use the underscore wildcard (_). This unique character is used in the LIKE operator to match a single character in a string. This wildcard is valid when searching for specific patterns in text data, primarily when the number of characters is known but the exact characters are not. For example, if you wanted to search for a six-letter word that starts with “C” and ends with “E,” you could use the following query:</p><pre>SELECT<br>*<br>FROM Items<br>WHERE <br>    item_name LIKE &#39;c____e&#39;</pre><p>Using the underscore wildcard, returns one row with “Cheese” in the item_name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*yD6eHMtj_qeT3ci0gZZ5CA.png" /></figure><p>Lastly, one thing to remember. Just as easily as you select these conditions using LIKE, you can easily reverse the conditions by using NOT LIKE.</p><h4>Separate numeric form non-numeric</h4><p>Consider the following scenario: using the store_name column, we want to separate the store number from the store name. First, take a look at the column values below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*Uz_gh9-gbU8eGGfheaFlSA.png" /><figcaption>store_name column values</figcaption></figure><p>The problem is that the column is not uniform regarding where the store number appears. One way to deal with this in SQL is by using the PATINDEX() function in combination with SUBSTRING(). The PATINDEX() function searches a string for a specified pattern and returns the starting position of the pattern within the string. In this example query, we are searching for a pattern of three consecutive digits using the text pattern %[0–9][0–9][0–9]%. Once we have identified the starting position of the pattern using PATINDEX(), we can use SUBSTRING() to extract the following three characters starting at that position. We will apply these functions to the column store_name and create a new column called store_number that contains just the three-digit number found within each store_name string.</p><pre>SELECT<br>    *<br>    ,SUBSTRING(store_name,PATINDEX(&#39;%[0-9][0-9][0-9]%&#39;,store_name), 3) store_number<br>FROM Items</pre><p>The resulting query yields this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYDMNNxdnUPcRmrKUU0GTw.png" /></figure><p>No matter where the store number is in the store_name string, we can identify it quickly using wild card patterns.</p><h4>Summary</h4><p>This article explores various techniques for filtering text data in SQL databases using techniques such as the WHERE clause and LIKE operator. The post also highlights the usefulness of functions like UPPER(), LOWER(), and CONCAT() to format and combine text data. In the last example, we used PATINDEX() and SUBSTRING() functions to separate numeric values from non-numeric text data. The techniques presented in the article can help data analysts and database administrators parse and extract useful information from large datasets containing text data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=207f6f76b38c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Joins 101: The Secret to Seamless Data Combination]]></title>
            <link>https://medium.com/@bthor10/sql-joins-101-the-secret-to-seamless-data-combination-617030953085?source=rss-783d06405cc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/617030953085</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[join]]></category>
            <category><![CDATA[case]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Ben Thornton]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 00:14:46 GMT</pubDate>
            <atom:updated>2023-01-22T00:14:46.228Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the best features of using SQL is the ability to combine large complex data sets, using joins. In a single query, this technique allows you to build new columns and derive new insights by using your already existing data. Let’s make sure we all have a good understanding before we begin!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zN_gWHTzl04SKSiv" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_source=medium&amp;utm_medium=referral">Shubham Dhage</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First off, let’s talk about tables. In SQL a table is just a collection of rows and columns. We can compare it to a spreadsheet, but with extra functionality such as programmatically filtering, updating, sorting, and deleting data. To explain let’s imagine a table that provides information regarding a customer, their order, and subsequent price. Rows in this table represent a single item, such as an order from a customer. The customer’s name and the order’s total price make up the columns, each representing information about that order. To harness this ability, you specify the join type, choose the table you want to link, and then state the columns that you are merging each table on. There are many types of joins, but I use the left join more than any other. Tables need to have columns to use as “keys” for combining. If you are blending two tables, they will combine to become a large table and all of the columns from both tables become available to select from.</p><h4>A Simple Demonstration</h4><p>Let’s say you have two tables; one with student information and another with assignment grades. The table regarding student information might have columns like <em>Student_ID</em>, <em>First_Name</em>, and <em>Last_Name</em>, while the assignment grade table might have columns like <em>Assignment_Name</em>, <em>Grade_Value</em>, and <em>Date_Updated</em>. If you want to get a list of all grades along with the student names, you’ll need to combine the data from these two tables. The column <em>Student_Key</em> will be the column we use to merge the two tables.</p><p>The basic syntax is pretty simple:</p><pre>SELECT<br>  #Student_Info.Student_Key,<br>  #Student_Info.Major,<br>  #Student_Grades.Student_Name,<br>  #Student_Grades.Assignment_Name,<br>  #Student_Grades.Grade_Value,<br>  #Student_Grades.Updated_Date<br>FROM #Student_Info<br>  LEFT JOIN #Student_Grades<br>    ON #Student_Info.Student_Key = #Student_Grades.Student_Key</pre><p>In this case, you have two tables: Student_Info and Student_Grades. You will end up with a single table with the columns <em>Student_Key</em> and <em>Major</em> from the Student_Info table along with <em>Student_Name</em>, <em>Assignment_Name</em>, <em>Grade_Value</em>, and <em>Updated_Date</em> from the Student_Grades table where each row will represent an assignment grade along with the student name and major. I use a left-join because I want all of the rows from the left table (Student_Info) and only the rows that match from the right table (Student_Grades).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*gfp5R8Coi01m3nxcnCQ0Ag.jpeg" /><figcaption>Table resulting from the query above</figcaption></figure><h4>Check Your Work</h4><p>It’s important to make sure you don’t duplicate data, so be sure to check that the number of rows you started with is the same number of rows you end with after blending. Let’s use the simple check, as seen below, to count the number of times your key appears in the new table. If your query worked correctly, you should return 0 rows.</p><pre>SELECT count(*)<br>FROM #temp<br>WHERE Student_Key in (<br>  SELECT<br>    Student_Key,<br>    count(*)<br>  FROM #temp<br>  GROUP BY <br>    Student_Key<br>  HAVING count(*) &gt; 1<br>)</pre><h4>Simplifying your code</h4><p>Joins are a game-changer when it comes to combining data from multiple tables in SQL. Instead of using cumbersome and hard-to-read case statements, they offer a more efficient and intuitive way to derive new columns using conditions from existing columns.</p><p>Let&#39;s revisit our student information and assignment grade example. We can easily create a new column that displays the student&#39;s minor by referencing their major from the student information table.</p><p>Using our resulting table from the previous example, let&#39;s join in a small table to get a students minor.</p><pre>SELECT #Students_Combined_Data.*,<br>  #Majors.Minor<br>FROM #Students_Combined_Data<br>  LEFT JOIN #Minors<br>    ON #Students_Combined_Data.Major = #Minors.Major</pre><p>In this example, we’re merging the the Students_Combined_Data and the Minors tables, based on the <em>Major</em> column in both tables. This allows us to utilize the <em>Minor</em> column, from the Minors table.</p><p>Using a case statement in this situation produces a query that is harder to read, but achieves the same result. The syntax would look something like this:</p><pre>SELECT #Students_Combined_Data.*,<br>  CASE<br>    WHEN #Students_Combined_Data.Major = &#39;Mechanical Engineering&#39; THEN &#39;Materials&#39;<br>    WHEN #Students_Combined_Data.Major = &#39;Computer Science&#39; THEN &#39;Analytics&#39;<br>    WHEN #Students_Combined_Data.Major = &#39;Business Management&#39; THEN &#39;Statistics&#39;<br>  ELSE<br>    &#39;None&#39;<br>  END Minor<br>FROM #Students_Combined_Data</pre><h4>In conclusion</h4><p>The next time you’re faced with the task of combining data from multiple tables, remember that joins are your trusty ally! They are a powerful tool that can help you make sense of the relationships between multiple datasets and are a big help when it comes to wrangling data. Keep on the lookout for situations where you have long complicated case statements and remember that joins can be used instead!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=617030953085" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>