<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Justin Chau</title>
    <description>The latest articles on DEV Community by Justin Chau (@chau_codes).</description>
    <link>https://dev.to/chau_codes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F301752%2Fa9d65d07-3715-46c2-9dec-97bfec8ece0f.jpg</url>
      <title>DEV Community: Justin Chau</title>
      <link>https://dev.to/chau_codes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chau_codes"/>
    <language>en</language>
    <item>
      <title>Working With JSON Objects Using SQL</title>
      <dc:creator>Justin Chau</dc:creator>
      <pubDate>Tue, 07 Jun 2022 21:38:33 +0000</pubDate>
      <link>https://dev.to/chau_codes/working-with-json-objects-using-sql-3ho5</link>
      <guid>https://dev.to/chau_codes/working-with-json-objects-using-sql-3ho5</guid>
      <description>&lt;p&gt;Recently, I have been teaching myself SQL to complete a project I have and one of the biggest problems I ran into was dealing with JSON objects in our companies data warehouse. I had no idea how to access the specific key pair values in the object, let alone access values within a JSON object wrapped in an array..&lt;/p&gt;

&lt;p&gt;None of the StackOverflow threads or any online resource really helped or explained this concept in a way for me to understand. So after two-ish hours of playing around with my queries, I finally got it to work. In this small guide, hopefully I can explain this in a much more simple way for everyone to understand. Let's get to it!&lt;/p&gt;

&lt;h2&gt;
  
  
  The UNNEST Function
&lt;/h2&gt;

&lt;p&gt;First it was essential for me to know about the &lt;code&gt;UNNEST&lt;/code&gt; function and what it allowed me to do. Simply put, if there are values that you need and they are &lt;em&gt;nested&lt;/em&gt; in an array, the &lt;code&gt;UNNEST&lt;/code&gt; function allows us to pass in the array as an argument and lets us access these nested values. Let's see an example.&lt;/p&gt;

&lt;p&gt;Say we have a column which is named &lt;code&gt;values&lt;/code&gt; and has a value that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['foo', 'bar', 'baz', 'qux', 'corge', 'garply', 'waldo', 'fred']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we wanted to get each &lt;strong&gt;individual&lt;/strong&gt; value from this array, we would write a SQL query that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM UNNEST(values) AS flattened_values;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query would then give us a new column named &lt;code&gt;flattened_values&lt;/code&gt; with each individual string in its own row like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dRLgsxY9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4uloac14w699e6u483nn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dRLgsxY9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4uloac14w699e6u483nn.png" alt="Example of array of strings" width="282" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Unnesting an Array of Objects
&lt;/h2&gt;

&lt;p&gt;Easy enough right? Now that we understand that, lets move into unnesting an &lt;strong&gt;array of objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Lets use a similar example but this time, some of those strings are going to be in their own objects, wrapped in an array like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{"name": "foo", "last_name": "bar"}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, we would need to make use of the &lt;code&gt;UNNEST&lt;/code&gt; function as well as the &lt;code&gt;JSON_EXTRACT_SCALAR&lt;/code&gt; function. Both of these functions working together help us reach into the array and extract a particular value from the object based on its key. &lt;/p&gt;

&lt;p&gt;First we will need to use the &lt;code&gt;UNNEST&lt;/code&gt; function to access the array and set that as a variable using the AS clause.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM UNNEST(names) AS flattened_names
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have the name of the column that contains the array, which is set to &lt;code&gt;flattened_names&lt;/code&gt;, we can select specific keys and grab their values using the &lt;code&gt;JSON_EXTRACT_SCALAR&lt;/code&gt; function like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
JSON_EXTRACT_SCALAR(flattened_names, '$.name') as first_name,
JSON_EXTRACT_SCALAR(flattened_names, '$.last_name') as last_name
FROM UNNEST(names) AS flattened_names
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So what is exactly happening here? Well since we have the array set to the name of &lt;code&gt;flattened_names&lt;/code&gt; we can access it through the &lt;code&gt;JSON_EXTRACT_SCALAR&lt;/code&gt; function. This function extracts a &lt;em&gt;scalar&lt;/em&gt; value which could be a string, number, or boolean. The first parameter we give the function is the array in which we want it to look at. In our case, we want it to look into the &lt;code&gt;flattened_names&lt;/code&gt; array. The second parameter is going to be the name of the key whose value we want to extract. We prefix the key name with a "$.{key_name_here}". This effectively would be equivalent to accessing this key in an object with syntax like &lt;code&gt;flattened_names.name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now that we've accessed the array, and extracted the individual values, running the query would then result in this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kwWm2cRG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wezz5yhniawabx3r3olo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kwWm2cRG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wezz5yhniawabx3r3olo.png" alt="Finalized result with query" width="416" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So there you have it! My super simple run-down of something I learned in SQL and hopefully that helped some of you out there. If there is anything you wanna discuss on this, please post em down in the comments and if you liked this, make sure to give it a reaction ☺️&lt;/p&gt;

&lt;p&gt;Hit me up on &lt;a href="https://twitter.com/chau_codes"&gt;Twitter&lt;/a&gt; to stay up-to-date on when a new blog post comes out! Thanks for reading.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>database</category>
    </item>
    <item>
      <title>The Best Way To Learn on the Job</title>
      <dc:creator>Justin Chau</dc:creator>
      <pubDate>Fri, 03 Jun 2022 23:54:57 +0000</pubDate>
      <link>https://dev.to/chau_codes/the-best-way-to-learn-on-the-job-4jlo</link>
      <guid>https://dev.to/chau_codes/the-best-way-to-learn-on-the-job-4jlo</guid>
      <description>&lt;p&gt;I've been in the industry now for 2 years after getting my first job as a Developer Support Engineer at Plaid. I never knew what to expect but I knew that I still had a lot to learn. As a self-taught developer, there are naturally some gaps in my knowledge that I need to fill. The question I asked myself so much is "how in the hell am I going to learn all this?".&lt;/p&gt;

&lt;p&gt;Being brand new to the role and the industry, I came in already overthinking every aspect of the job and feeling like there was this high expectation to deliver that I needed to hit. But I found out very early on what I had to do in order to fill in the gaps and bring as much impact as possible to the team!&lt;/p&gt;

&lt;p&gt;And that was to:&lt;/p&gt;

&lt;h2&gt;
  
  
  Leverage Your Co-Workers!
&lt;/h2&gt;

&lt;p&gt;There was an invaluable resource readily available to me that I completely overlooked.. And that was my co-workers. These are individuals that have been in the trenches way longer than I have! They have seen and done the things I dreamt of doing so I started to leverage them and became a sponge, soaking up as much knowledge as I could.&lt;/p&gt;

&lt;p&gt;I asked them questions whenever I could. Being an introvert myself, it was hard at first to get out of my comfort zone and actually talk to people. Yes.. weird I know but I do suffer from social anxiety. Over the years, I have learned to somewhat overcome this. I'd love to tackle this in another blog post if people are interested!&lt;/p&gt;

&lt;h2&gt;
  
  
  Becoming a Sponge
&lt;/h2&gt;

&lt;p&gt;Anytime I struggled on a certain bug/problem, I asked in related Slack channels so individuals from that respective team could give me an answer. If it still wasn't clear, I'd keep poking until I understood. Eventually I identified the people that explained certain concepts in a way I could understand and were willing to hop on calls to explain them further.&lt;/p&gt;

&lt;p&gt;Those are the people I'd naturally gravitate towards and who I have learned from the most. Without them, it would've taken me even longer to learn something either from scratch or sifting through StackOverflow questions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Moral of the story here is to use the resources that are right in front of you. It might seem intimidating at first (and trust me, I still get anxiety doing it now), but it will be the best thing you'll ever do. &lt;/p&gt;

&lt;p&gt;In March of 2022, I started a new role as a Developer Advocate at &lt;a href="https://airbyte.com/"&gt;Airbyte&lt;/a&gt;, making the transition from more of a Frontend focus to a Data Engineering focus. This in itself is one of the biggest challenges I am currently going through. But being surrounded by Data Engineers and Data Analysts, I know I will get through this 😉&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this blog post! Hit me up on &lt;a href="https://twitter.com/Chau_codes"&gt;Twitter&lt;/a&gt; if ya have any questions and to see when a new blog post comes out! See ya in the next one 🙏🏽&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>My MongoDB Atlas Hackathon Submission!</title>
      <dc:creator>Justin Chau</dc:creator>
      <pubDate>Fri, 14 Jan 2022 03:44:42 +0000</pubDate>
      <link>https://dev.to/chau_codes/my-mongodb-atlas-hackathon-submission-33op</link>
      <guid>https://dev.to/chau_codes/my-mongodb-atlas-hackathon-submission-33op</guid>
      <description>&lt;h3&gt;
  
  
  Overview of My Submission
&lt;/h3&gt;

&lt;p&gt;The application I built is a YouTube Video Planner which loosely simulates a Notion template I use to track what YouTube videos I plan on creating. I thought it would be a better idea to have a dedicated location where I can track these videos and what better way than to do it for this hackathon as my project! &lt;/p&gt;

&lt;p&gt;As of right now, it is a very barebones application to where it essentially functions the same as a todo app but I do plan on working on this more. I built this with NextJS, Graphql, Apollo, Prisma and MongoDB as my stack of choice! &lt;/p&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;Choose Your Own Adventure&lt;/p&gt;

&lt;h3&gt;
  
  
  Link to Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/chaucodes/youtube-video-planner"&gt;Github repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>atlashackathon</category>
    </item>
    <item>
      <title>The One Thing You Should Prioritize As A Developer</title>
      <dc:creator>Justin Chau</dc:creator>
      <pubDate>Mon, 26 Oct 2020 19:20:03 +0000</pubDate>
      <link>https://dev.to/chau_codes/the-one-thing-you-should-prioritize-as-a-developer-23o7</link>
      <guid>https://dev.to/chau_codes/the-one-thing-you-should-prioritize-as-a-developer-23o7</guid>
      <description>&lt;p&gt;After talking with so many different developers and listening to their experiences, there is one thing that I learned to really focus on. It is something that we often overlook and never really pay attention to it until we reach the tipping point. This really needs to be at the forefront of the conversation when it comes to being a developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thats Mental Health
&lt;/h3&gt;

&lt;p&gt;Again, this is something we often overlook as devs. We can get carried away with "The Grind" or "The Hustle" when in reality, learning to code should be where we deploy patience and consistency over time. Not this idea of working/learning all day every day cause thats what we think we need to do to make it big as a developer. Completely not the case here.&lt;/p&gt;

&lt;p&gt;Instead, we should take it one day at a time at a pace that is reasonable and maintainable. Learning how to control our pace will not only help us be more productive, but it will also keep us farther away from &lt;strong&gt;burnout&lt;/strong&gt;. No one likes to burnout, especially when it comes to something we love to do! Which makes it even more important to stay at a steady pace.&lt;/p&gt;

&lt;p&gt;Along with pacing, we need to take more time for our personal lives. That means taking breaks to go outside for a run, hangout with friends/family, read a book or anything that isn't related to your work! Having our minds wrapped around our work all the time is not only unhealthy, but counterintuitive. It is something I learned the hard way and don't want to see anyone else go through. I almost quit everything because of this very problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Short and sweet for my first blog post on a topic that is super important to me. Hope you got something out of that and if you want a more detailed explanation from me on this topic, check out my recent YouTube video that I made below! Let me know what you think in the comments! &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/bIvBvKqPcwo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>mentalhealth</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
