<?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: Rahul Dubey</title>
    <description>The latest articles on DEV Community by Rahul Dubey (@rahuldubey391).</description>
    <link>https://dev.to/rahuldubey391</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%2F1029406%2F8da2b2ed-7447-410e-823a-74bb6b6ebd82.png</url>
      <title>DEV Community: Rahul Dubey</title>
      <link>https://dev.to/rahuldubey391</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahuldubey391"/>
    <language>en</language>
    <item>
      <title>Metadata for win — Apache Parquet</title>
      <dc:creator>Rahul Dubey</dc:creator>
      <pubDate>Sat, 25 May 2024 08:36:09 +0000</pubDate>
      <link>https://dev.to/rahuldubey391/metadata-for-win-apache-parquet-3mb5</link>
      <guid>https://dev.to/rahuldubey391/metadata-for-win-apache-parquet-3mb5</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfprkiffa2suu2h6zxu5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfprkiffa2suu2h6zxu5.jpg" alt="https://github.com/RahulDubey391/parquet-reader" width="800" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You read the title right! Apache Parquet provisions best of the data properties to optimize your data processing engine capabilities. Some of the popular Distributed Computing solutions like Apache Spark, Presto exploits this property of Apache Parquet to read/write data faster.&lt;/p&gt;

&lt;p&gt;Also, enterprise solutions in market like Databricks provides ACID properties on top of the Apache Parquet format to build Delta Tables. Some new formats have also arrived like Apache Iceberg, Apache Hudi etcetera.&lt;/p&gt;

&lt;p&gt;But how it works? What if you have to write your own custom processing solution when it’s desired to use a needle instead of sword like Apache Spark.&lt;/p&gt;

&lt;p&gt;Often, setting up Apache Spark is another big elephant which most people shy away from if they just want to process a manageable size on in single system.&lt;/p&gt;

&lt;p&gt;For such cases, Apache Arrow is the best solution. Although it’s a platform that is language agnostic, it can be used for a single machine processing. Other libraries like Polars can also be used for single machine processing.&lt;/p&gt;

&lt;p&gt;But how these frameworks makes the best out of Apache Parquet format? It’s the columnar format and the inherent structure of the file. The file is structured in such a format that retrieving columns is much efficient than the row based retrieval. In fact, the columns which are only required for analytical processing queries are preferred to be retrieved instead of selecting all columns as a whole.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is file structured?
&lt;/h2&gt;

&lt;p&gt;Apache Parquet is optimized for analytical processing queries which is why it follows columnar format approach. Referring to the below official illustration, I’ll explain how it work:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklkmxw8wiz3dfdbwxppn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklkmxw8wiz3dfdbwxppn.png" alt="Source — https://parquet.apache.org/docs/file-format/" width="601" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What’s going on in the above illustration? Let me explain.&lt;/p&gt;

&lt;p&gt;File is structured in parts, where it has 5 crucial information:&lt;/p&gt;

&lt;h2&gt;
  
  
  Header
&lt;/h2&gt;

&lt;p&gt;Header provides information regarding the official file format named as Magic Number — “PAR1”. This information is mostly specific to designate that it’s a Parquet format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data
&lt;/h2&gt;

&lt;p&gt;The actual data is stored in Data part of the file. It’s a combination of Row Groups + Column Chunks + Pages. Don’t worry we’ll come to it when we discuss about Footer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Footer
&lt;/h2&gt;

&lt;p&gt;Footer is main block of information we are interested in and this article is about that only. Footer holds some of the critical information which is exploited by processing frameworks to optimize read and write operation.&lt;/p&gt;

&lt;p&gt;It contains metadata about the whole file. It’s written during the write time of the file inherently to keep track of information so that it can be used during read time. High-level metadata we are interested in are as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FileMetadata&lt;/strong&gt; — Metadata block containing information about the file like Schema, Version of the parquet etcetera.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RowGroupMetadata&lt;/strong&gt; — This one holds metadata about the column chunk names, number of records per row group etcetera.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ColumnMetadata&lt;/strong&gt; — Column metadata tells information about each column like Name, Values (Distinct if needed), Compression Type, Offset to data page, Column Statistics like Min, Max values, byte size etcetera.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PageMetadata&lt;/strong&gt; — Pages are blocks containing the actual data where it’s broken down to multiple pages. Each page metadata contains the next offset value to access the page.&lt;/p&gt;

&lt;p&gt;There are are metadata information like Indexed columns and other which can be set while writing the file.&lt;/p&gt;

&lt;p&gt;If you want to know how it looks as compiled bytes to string, you can see the similar structure as below:&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
    SOURCE - &lt;a href="https://parquet.apache.org/docs/file-format/metadata/"&gt;https://parquet.apache.org/docs/file-format/metadata/&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4-byte magic number "PAR1"
&amp;lt;Column 1 Chunk 1 + Column Metadata&amp;gt;
&amp;lt;Column 2 Chunk 1 + Column Metadata&amp;gt;
...
&amp;lt;Column N Chunk 1 + Column Metadata&amp;gt;
&amp;lt;Column 1 Chunk 2 + Column Metadata&amp;gt;
&amp;lt;Column 2 Chunk 2 + Column Metadata&amp;gt;
...
&amp;lt;Column N Chunk 2 + Column Metadata&amp;gt;
...
&amp;lt;Column 1 Chunk M + Column Metadata&amp;gt;
&amp;lt;Column 2 Chunk M + Column Metadata&amp;gt;
...
&amp;lt;Column N Chunk M + Column Metadata&amp;gt;
File Metadata
4-byte length in bytes of file metadata (little endian)
4-byte magic number "PAR1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;h2&gt;
  
  
  Using metadata in practice
&lt;/h2&gt;

&lt;p&gt;Discussed File Structure and Metadata can be used to write efficient systems for retrieving and processing large amount of files. In this section we are going to discuss how you can utilize the above information to benefit your program for read and processing logic.&lt;/p&gt;

&lt;p&gt;Often the mistakes are made during the write time itself. Most people ignore the benefits of Parquet format and considers it like just any other file format like CSV, TSV etc. But if done right, some extra parameters can be used to apply these properties like Sorting based on low-cardinality columns, applying indexing based on a column, sorting the metric columns with high cardinality for co-locating values closer to a range.&lt;/p&gt;

&lt;p&gt;Let’s not waste time and dive into a real example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data in practice
&lt;/h2&gt;

&lt;p&gt;We are going to utilize a script to generate some random data with a structure. The script will produce 100k records per file with 100 files in total. We will add some extra parameters to force some conditions for efficient reads at first like sorting based on columns. This data will be stored in a GCS bucket. Since most production environments are based on cloud, the blob storage systems are used to handle concurrent read/writes by the processing solutions.&lt;/p&gt;

&lt;p&gt;Data points are scattered randomly across the files, since this is a challenge for most processing engines to spread the reads across 80–90% of the files in question. It’s also a worst case to handle and test our processing system.&lt;/p&gt;

&lt;p&gt;Refer the below code to generate some data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metadata Collection and Filtering Processes
&lt;/h2&gt;

&lt;p&gt;We’ll divide our codebase into two parts, first is Metadata Collection process which will be responsible for reading metadata across all 100 files and writing it to a metadata folder at the same path where other files exists. Second part is the filtering process, which will take some random Query Parameters as arguments and based on this, collected metadata will be searched for filtering out only those part of the files that we require to read the records.&lt;/p&gt;

&lt;p&gt;We are going to utilize Multiprocessing module in Python to maximize the reading and writing of metadata. Remind you, we are also going to utilize the Apache Arrow for just reading metadata and memory mapping the files while reading actual data.&lt;/p&gt;

&lt;p&gt;In the cover image, each process is part of 2 classes. Collection and Write process are part of MetadataCollector class and Filter and Data Collection processes are part of MetadataProcessor class.&lt;/p&gt;

&lt;p&gt;Both the classes provide executable methods for multiprocessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Experiment in Consideration
&lt;/h2&gt;

&lt;p&gt;I took around 20 GB of user clicks data that I generated from a script, it has the following configuration:&lt;/p&gt;

&lt;p&gt;No partitiong logic — random splits&lt;br&gt;
No ordering of the columns — predicate pushdown process most probably read all files while filtering&lt;br&gt;
Row Group size is kept 100K records per page&lt;br&gt;
Number of Rows per file — 1M&lt;br&gt;
Compression Type — Snappy&lt;/p&gt;

&lt;h2&gt;
  
  
  Compute Engine
&lt;/h2&gt;

&lt;p&gt;The Google Cloud Compute Engine service is used to run the module. It has the following configuration:&lt;/p&gt;

&lt;p&gt;4 vCPUs (2 Cores)&lt;br&gt;
16 GB Memory&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance
&lt;/h2&gt;

&lt;p&gt;Whole process took around 1.1 minutes (29 seconds for Metadata Collection and 34 seconds for Metadata Filtering and Data Collection)&lt;/p&gt;

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

&lt;p&gt;Although the processing with Python suffers a lot of draw back, but the module provides a basic understanding on how Apache Parquet can be used efficiently for better I/O operations. Future scope would be to use Bloom Filters, Sort-Merge Compaction, Z-Ordering (Key Co-location per file) and some other tricks to make it more mature.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Repository
&lt;/h2&gt;

&lt;p&gt;Refer to the below GitHub link to run check and run your own process. The code is not mature and it lacks proper constructs, but it’s still a WIP so feel free to add any suggestion or PR maybe.&lt;/p&gt;

&lt;p&gt;parquet-reader — &lt;a href="https://github.com/RahulDubey391/parquet-reader"&gt;https://github.com/RahulDubey391/parquet-reader&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>bigdata</category>
      <category>datascience</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>💻Ephemeral UI: React + Nginx + Docker + Cloud Run☁</title>
      <dc:creator>Rahul Dubey</dc:creator>
      <pubDate>Tue, 11 Apr 2023 08:00:57 +0000</pubDate>
      <link>https://dev.to/rahuldubey391/ephemeral-ui-react-nginx-docker-cloud-run-30o0</link>
      <guid>https://dev.to/rahuldubey391/ephemeral-ui-react-nginx-docker-cloud-run-30o0</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ktnc7bdzphkwt6umw7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ktnc7bdzphkwt6umw7y.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi🤗, In this tutorial, we are going to implement and deploy a basic React App on Google Cloud Run using Docker, Google Cloud Shell and of course a GCP account!&lt;/p&gt;

&lt;p&gt;Before going forward, you might ask what's Cloud Run? What is Ephemeral UI here means?&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloud Run - Developer's best friend 😎
&lt;/h2&gt;

&lt;p&gt;Google Cloud Platform provide several services to deploy light weight application such as Cloud Functions, App Engine and finally Cloud Run. All these services are serverless and doesn't maintain application's state. &lt;/p&gt;

&lt;p&gt;Behind the scene, these are Knative Application which are deployed during the invocation over Kubernetes Engine aka GKE. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wait, What🧐? if its serverless how is it useful for Front-End Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where the term &lt;strong&gt;Ephemeral UI&lt;/strong&gt; comes into the picture. These application are only specific for a small session where a quick summary or information needs to be received and then the consumer will move away.&lt;/p&gt;

&lt;p&gt;Such is the case when you as a consumer wants to do some analysis lets say collect Sales Prediction in future for a product, download the rep-sheet and just woosh away!&lt;/p&gt;

&lt;p&gt;Apart from being cursory usage, it is also a good idea to develop and deploy quick UI prototypes on these light weight serverless services, since it won't cost you for sitting idle!!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Before moving forward you need following things to be setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GCP Account&lt;/li&gt;
&lt;li&gt;Google Cloud Shell&lt;/li&gt;
&lt;li&gt;NodeJS&lt;/li&gt;
&lt;li&gt;ReactJS&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup Simple React App
&lt;/h2&gt;

&lt;p&gt;In this section, we will create a simple React App that takes user's name as input and returns Hello with name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzl25zmgr5j5rc3fyzji.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzl25zmgr5j5rc3fyzji.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo01bkddnox12obrvvfal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo01bkddnox12obrvvfal.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To create this step, use the following code:&lt;/p&gt;

&lt;p&gt;Install React&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react react-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, change to some directory and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app hello-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, change to directory and run the app, it will show a React logo animation on the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;cd hello-app
&amp;gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it is confirmed that React is installed correctly, use the below code in &lt;code&gt;App.js&lt;/code&gt; file to create the desired app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';

function App() {
  const [inputValue, setInputValue] = useState('');

  const handleInputChange = (event) =&amp;gt; {
    setInputValue(event.target.value);
  };

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    alert(`Hello ${inputValue}!`);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Enter your name:&amp;lt;/h1&amp;gt;
      &amp;lt;form onSubmit={handleSubmit}&amp;gt;
        &amp;lt;input type="text" value={inputValue} onChange={handleInputChange} /&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you save the file, the changes will be automatically loaded and it will be visible on local host.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting-Up Nginx Configuration
&lt;/h2&gt;

&lt;p&gt;While it is good to test the app locally first before deploying it, you have to follow some extra steps to make the application discoverable on the internet. Nginx provides the way for deploying your app in production setting.&lt;/p&gt;

&lt;p&gt;But before this, you have to setup an Nginx configuration file while deploying in container. In your root directory, create a file name &lt;code&gt;nginx.conf&lt;/code&gt; and paste following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
  listen 80;
  sendfile on;
  default_type application/octet-stream;

  gzip on;
  gzip_http_version 1.1;
  gzip_disable      "MSIE [1-6]\.";
  gzip_min_length   256;
  gzip_vary         on;
  gzip_proxied      expired no-cache no-store private auth;
  gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  gzip_comp_level   9;

  root /usr/share/nginx/html;

  location / {
    try_files $uri $uri/ /index.html =404;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Finally, Dockerfile!
&lt;/h2&gt;

&lt;p&gt;At last, before deployment, you have to do one more step to containerize the application in Docker Container using Dockerfile. The file contains commands similar to Linux commands and such is the case with Docker since it's a OS/Hardware virtualization layer.&lt;/p&gt;

&lt;p&gt;Create a file named &lt;code&gt;Dockerfile&lt;/code&gt; at the root of your app's directory and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:16.13.1 as build

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build --prod

FROM nginx:latest AS ngi

COPY --from=build /app/build /usr/share/nginx/html

COPY /nginx.conf  /etc/nginx/conf.d/default.conf

EXPOSE 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we mention the steps to run npm build and nginx deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy with Google Cloud Shell 🚀
&lt;/h2&gt;

&lt;p&gt;Before moving ahead, make sure you have Google Cloud Shell installed as well as you have service account JSON credentials. Using Google Cloud Shell allows to bypass the Cloud Build or npm build step in the local, so you can directly run build in the container itself.&lt;/p&gt;

&lt;p&gt;Type the following command to discover and activate the appropriate service account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud auth list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will show list of all the service accounts. If nothing is shown use this instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud auth activate-service-account &amp;lt;SERVICE-ACCOUNT-NAME&amp;gt; --key-file=&amp;lt;PATH/TO/JSON&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once, it is done, you will get activated notification. After this type change to the root of the App directory and type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud run deploy hello-app --port 80 --allow-unauthenticated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it is done, you will start to see build wheel mentioning container initialization and service feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Time to Go!
&lt;/h2&gt;

&lt;p&gt;That's it folks! here we wrap up the tutorial. In this we learned end-to-end deployment of React application on GCP. In the next tutorial, we will show how to setup a CI/CD pipeline to automate the build and deployment of the application.&lt;/p&gt;

&lt;p&gt;Take a moment to cherish that you have come this far!👾&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to Github&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.tourl"&gt;https://github.com/RahulDubey391/React-On-Cloud-Run&lt;/a&gt; &lt;/p&gt;

</description>
      <category>docker</category>
      <category>googlecloud</category>
      <category>react</category>
    </item>
    <item>
      <title>Make it Go! - Introduction</title>
      <dc:creator>Rahul Dubey</dc:creator>
      <pubDate>Sun, 12 Mar 2023 15:58:35 +0000</pubDate>
      <link>https://dev.to/rahuldubey391/make-it-go-introduction-4am5</link>
      <guid>https://dev.to/rahuldubey391/make-it-go-introduction-4am5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s5FIj3Js--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l5dprl2z4av7bwpi2ao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s5FIj3Js--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l5dprl2z4av7bwpi2ao.png" alt="Image description" width="299" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it comes to choosing programming languages for your app which might be data-intensive and needs to have low computation latency, developers have to make a choice between better readability/fast development vs high-performance. Often the languages that have better readability and fast-prototyping lacks performance and it becomes main bottleneck when your app needs to serve millions of user requests.&lt;/p&gt;

&lt;p&gt;This is the where Go comes in. Now I must tell you before moving ahead in the discussion that I have been always a Python guy due to its simplicity, fast development and better number of packages available from community and of course data!!! Python has a large number of packages available for doing ML/AI, Data Science, Data Analytics and Big Data tasks. But still it has a lot of drawbacks. Some of them according to me are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First its an &lt;strong&gt;Interpreted dynamic language&lt;/strong&gt;. Dynamic because the data mutability is allowed during the runtime which is by nature slow and can add significant latency issues.&lt;br&gt;
Portability is another issue. The distribution of Python applications requires the consumer machines to have Python Interpreter installed locally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No better way for &lt;strong&gt;Inter-Process Communication (IPC)&lt;/strong&gt;. The processes running in parallel needs to have a common queue or buffer in-place to allow processes share information among each other. There are middle-wares like Celery, Redis etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And Of course &lt;strong&gt;Concurrency&lt;/strong&gt;! By default Python is not concurrent. This is due to the infamous &lt;strong&gt;GIL(Global Interpreter Lock)&lt;/strong&gt; which restricts multiple threads running at the same time. There are some libraries which tries to outsmart the GIL like Asyncio, Futures etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the drawback list can go on. My Job requires me to build and deploy a lot of custom applications to handle Big Data problems. Often I have to deal with Small Files Problem which is also a boon to many existing Big Data Frameworks like Apache Hadoop, Apache Spark. There are many new player in the field like Ray, Dask, Modin which allows you write thread safe concurrent and parallel application for Big Data problems.&lt;/p&gt;

&lt;p&gt;In my belief, choosing an alternative to Python can be a great advantage when it comes to writing highly performant code. For me, Go is the first choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  A little history about Go
&lt;/h2&gt;

&lt;p&gt;Go was officially developed by Google to support its ongoing projects. Three of the Google Engineers named Robert Griesemer, Rob Pike, and Ken Thompson came up with the development plan for a programming language that can solve the issues with existing language like C++. They wanted simplicity of syntax but performance and features from languages such as C. They started developing Go September 21 2007 and after 2 years, the language was officially released as open-source project.&lt;/p&gt;

&lt;p&gt;Today many of the projects are using Golang. Such as:&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker
&lt;/h2&gt;

&lt;p&gt;Go is popular among DevOps community, especially with Docker. It has a 90% codebase of Go. Docker is popular for application containarization and widely accepted by community, organizations etc.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/docker" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--_kZeTDZQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://avatars.githubusercontent.com/u/5429470%3Fs%3D280%26v%3D4" height="280" class="m-0" width="280"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/docker" rel="noopener noreferrer" class="c-link"&gt;
          Docker · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Docker helps developers bring their ideas to life by conquering the complexity of app development. - Docker
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--uPIa4SpL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.githubassets.com/favicons/favicon.svg" width="32" height="32"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Kubernetes
&lt;/h2&gt;

&lt;p&gt;Kubernetes is another project that is developed using Go. It is one of the popular platform for orchestrating Docker Containers. It benefits the application by providing automated container scaling and much more.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kubernetes"&gt;
        kubernetes
      &lt;/a&gt; / &lt;a href="https://github.com/kubernetes/kubernetes"&gt;
        kubernetes
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Production-Grade Container Scheduling and Management
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Kubernetes (K8s)&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://bestpractices.coreinfrastructure.org/projects/569" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/0238a7ac2531a99a681c6eb6d9be15f5fa67411da6e40453fc676245e2bc073f/68747470733a2f2f626573747072616374696365732e636f7265696e6672617374727563747572652e6f72672f70726f6a656374732f3536392f6261646765" alt="CII Best Practices"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kubernetes/kubernetes/raw/master/logo/logo.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bh6lgk38--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kubernetes/kubernetes/raw/master/logo/logo.png" width="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes, also known as K8s, is an open source system for managing &lt;a href="https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/" rel="nofollow"&gt;containerized applications&lt;/a&gt;
across multiple hosts. It provides basic mechanisms for deployment, maintenance
and scaling of applications.&lt;/p&gt;
&lt;p&gt;Kubernetes builds upon a decade and a half of experience at Google running
production workloads at scale using a system called &lt;a href="https://research.google.com/pubs/pub43438.html" rel="nofollow"&gt;Borg&lt;/a&gt;
combined with best-of-breed ideas and practices from the community.&lt;/p&gt;
&lt;p&gt;Kubernetes is hosted by the Cloud Native Computing Foundation (&lt;a href="https://www.cncf.io/about" rel="nofollow"&gt;CNCF&lt;/a&gt;)
If your company wants to help shape the evolution of
technologies that are container-packaged, dynamically scheduled,
and microservices-oriented, consider joining the CNCF.
For details about who's involved and how Kubernetes plays a role,
read the CNCF &lt;a href="https://cncf.io/news/announcement/2015/07/new-cloud-native-computing-foundation-drive-alignment-among-container" rel="nofollow"&gt;announcement&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
To start using K8s&lt;/h2&gt;
&lt;p&gt;See our documentation on &lt;a href="https://kubernetes.io" rel="nofollow"&gt;kubernetes.io&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Try our &lt;a href="https://kubernetes.io/docs/tutorials/kubernetes-basics" rel="nofollow"&gt;interactive tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Take a free course on &lt;a href="https://www.udacity.com/course/scalable-microservices-with-kubernetes--ud615" rel="nofollow"&gt;Scalable Microservices with Kubernetes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To use Kubernetes code as a library in other applications, see the &lt;a href="https://git.k8s.io/kubernetes/staging/README.md" rel="nofollow"&gt;list&lt;/a&gt;…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kubernetes/kubernetes"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Benefits and Drawbacks
&lt;/h2&gt;

&lt;p&gt;There are a lot of benefits to Go when I try to compare it Python. Some of these are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Statically Complied Language&lt;/strong&gt;. Compared to Python, Go enforces type definitions to be applied to variable which are immutable during the runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Readability&lt;/strong&gt; is almost similar to Python so if you are transitioning from Python to Go, then the learning curve will be less steep. This also enables faster application development time and developer can be productive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;IPC&lt;/strong&gt;s are much easier than Python and kind of native to Go. Go has Channels which allows communication between the routines running in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Of course &lt;strong&gt;Concurrency&lt;/strong&gt; is main benefit of Go. Go handles concurrency by Go Routines and Channels.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although, transitioning to Go can be a bit difficult in the beginning due to following reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No OOP&lt;/strong&gt; concepts in Go. Go is a Procedural language and sits - somewhere between Fortran, C etc. Go has Generics, Interfaces and Modules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go doesn’t have &lt;strong&gt;Exceptions&lt;/strong&gt; and deals with bugs by producing &lt;strong&gt;Errors&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go is also has a &lt;strong&gt;Garbage Collector&lt;/strong&gt; similar to Python which makes it less performant than Rust, C++.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go allows &lt;strong&gt;Pointers&lt;/strong&gt; which can be dauting if you have never used these in your life.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Besides all these drawbacks, Go can be your best friend if you want to write highly performant backend systems with performance near to C and readability similar to Python. Also Go is becoming a popular language and most of the organizations are shifting to Go for their data intensive backend systems, so this means there will be a lot of demand for Go Developers in the market with Fat Paycheck.&lt;/p&gt;

&lt;p&gt;Keeping the monetary value aside, I think you should learn Go if you are already a Python developer. It can give you an edge in terms of dealing with building high-performant systems.&lt;/p&gt;

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

&lt;p&gt;In this article, we discussed about how Go can be your best bet when you want to write highly performant code. The language is still fresh and growing day-by-day. Community has been contributing to the project and provided some of the best frameworks and libraries.&lt;/p&gt;

&lt;p&gt;In the next article we will discuss how to create basic programs in Go. Till then Goodbye!!&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Using DAG to deal with Zip file for Snowflake</title>
      <dc:creator>Rahul Dubey</dc:creator>
      <pubDate>Sun, 19 Feb 2023 08:10:49 +0000</pubDate>
      <link>https://dev.to/rahuldubey391/using-dag-to-deal-with-zip-file-for-snowflake-31lo</link>
      <guid>https://dev.to/rahuldubey391/using-dag-to-deal-with-zip-file-for-snowflake-31lo</guid>
      <description>&lt;p&gt;In this article, we are going to cover how to deal with Zip files when loading into Snowflake using Airflow in GCP Composer. Its a typical data pipeline, but still can be tricky to deal with if you are a beginner or never dealt with ETL altogether.&lt;/p&gt;

&lt;p&gt;Before going further, we assume that you have the following services enabled:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Cloud Platform Account&lt;/li&gt;
&lt;li&gt;Snowflake Account&lt;/li&gt;
&lt;li&gt;GCP Composer Environment with basic integration setup with Snowflake&lt;/li&gt;
&lt;li&gt;Code Editor&lt;/li&gt;
&lt;li&gt;Python Installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Case Study&lt;/strong&gt;&lt;br&gt;
Suppose, you are working for a renowned organization that has recently shifted their data platform from BigQuery to Snowflake. Now all your organization's data is housed in Snowflake and all BI/DataOps happens exclusively in Snowflake.&lt;/p&gt;

&lt;p&gt;One fine morning, you are assigned a task to build a data pipeline to do Attribution Analytics. All the Attribution data is  dropped in GCS bucket in the form of Zip files from organization's partner. I know what you are thinking, you can just create a 'COPY INTO ' statement with a File Format enabling 'COMPRESSION=ZIP'. But this is not true, you can't use 'ZIP' directly in File Format. Also you can't use 'DEFLATE' type. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do?&lt;/strong&gt;&lt;br&gt;
You can utilize the GCP's capabilities to orchestrate and automate the data loading. But first, you have to ensure that there is an integration Object created in Snowflake to GCP Bucket. After this you create an external stage to locate the path in GCS bucket for direct loading.&lt;/p&gt;

&lt;p&gt;Once the above things are taken care of, you can now implement a DAG script for GCP Composer. GCP Composer is a managed Apache Airflow service, which enables quick deployment of Airflow on top of Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Airflow to the rescue&lt;/strong&gt;&lt;br&gt;
Apache Airflow is an elegant task scheduling service that allow Data Operation to be handled in effective and efficient manner. It provides an intuitive Web UI which allows users to manage task workflows. You can also create parallel workflows without the headache of creating own custom application dealing with Multiprocessing, Threads, Concurrency.&lt;/p&gt;

&lt;p&gt;Enough with the introductions, let's start coding.&lt;/p&gt;

&lt;p&gt;First you have to open you code editor and create a Python file. Name it as &lt;code&gt;DAG_Sflk_loader.py&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;After the above step, import all the necessary packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datetime import datetime,timedelta,date
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.contrib.operators.snowflake_operator import SnowflakeOperator
import pandas as pd
from google.cloud import storage
import zipfile
import io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To declare a DAG script, you have to use DAG object from airflow package 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;default_args = {
    'owner': 'ORGANIZATION',
    'start_date': datetime(2023, 2, 19),
    'email': ['username@email.com'],
    'email_on_failure': True,
    'email_on_retry': False
}

dag = DAG('SFLK_ZIP_LOAD', description = 'This DAG is loads ZIP files to snowflake', max_active_runs=1, catchup=False,default_args=default_args)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, first we define the arguments to be passed to DAG object like 'owner','start_date','email','email_on_failure' etc. After this we create a Context Manager for data pipeline using DAG object.&lt;/p&gt;

&lt;p&gt;Alright, now is the time to start defining custom tasks in Python and Snowflake. For this, we use Operators. Operators are individual task units that can be of any kind like Snowflake SQL, Python, Bash command, GSUtil etc. For our discussion, we will only use Python and Snowflake Operator.&lt;/p&gt;

&lt;p&gt;We will distribute our data pipeline in the following way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TRUNCATE_TABLE_TASK --&amp;gt; UNZIP_FILES_IN_GCS_TASK --&amp;gt; LOAD_FILES_TO_TABLE_TASK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TRUNCATE TASK&lt;/strong&gt;&lt;br&gt;
Before loading the data to Snowflake, we will first truncate the table. This is an incremental load, so we won't be using &lt;code&gt;TRUNCATE TABLE &amp;lt;TABLE_NAME&amp;gt;&lt;/code&gt; directly. We will just delete data for &lt;code&gt;CURRENT_DATE&lt;/code&gt; if present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TRUNC_QUERY = '''DELETE FROM &amp;lt;DATABASE_NAME.SCHEMA_NAME.TABLE_NAME&amp;gt; WHERE &amp;lt;DATE_FIELD&amp;gt; = CURRENT_DATE'''

trunc_task = SnowflakeOperator(
               task_id='TRUNCATE_TASK',
               sql=[TRUNC_QUERY],
               snowflake_conn_id='&amp;lt;connection_id&amp;gt;',
               database='&amp;lt;DATABASE_NAME&amp;gt;',
               schema='&amp;lt;SCHEMA_NAME&amp;gt;',
               warehouse = '&amp;lt;DATAWAREHOUSE_NAME&amp;gt;',
               role = '&amp;lt;ROLE_NAME&amp;gt;',
               dag=dag) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;UNZIPPING TASK&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For unzipping files in GCS bucket, we will use three libraries&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;zipfile&lt;/li&gt;
&lt;li&gt;io&lt;/li&gt;
&lt;li&gt;google-cloud-storage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, we define this task as a Python callable. This callable is used by Python Operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def unzip_file_in_gcs(**context):
    #Define GCS Client parameters
    bucket_name = '&amp;lt;BUCKET_NAME&amp;gt;'
    file_name = '&amp;lt;FILE_NAME&amp;gt;.zip'

    # Connect to the GCS bucket
    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(file_name)

    # Download the zip file to memory
    zip_file_content = blob.download_as_string()

    # Unzip the file
    zip_file = zipfile.ZipFile(io.BytesIO(zip_file_content))
    zip_file.extractall(path='/home/airflow/gcs/data/temp/')

    # Upload each file in the zip to the GCS bucket
    with open('/home/airflow/gcs/data/temp/&amp;lt;FILE_NAME&amp;gt;.csv', 'rb') as f:
        file_content = f.read()
        new_blob = bucket.blob('&amp;lt;FILE_NAME&amp;gt;.csv')
        new_blob.upload_from_string(file_content)

unzip_task = PythonOperator(
        task_id="UNZIP_TASK",
        python_callable=unzip_file_in_gcs,
        provide_context=True,
        dag=dag
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LOADING TASK&lt;/strong&gt;&lt;br&gt;
Once unzipping is done, now you can use &lt;code&gt;COPY INTO &amp;lt;TABLE_NAME&amp;gt;&lt;/code&gt; statement to load the data into Snowflake table.&lt;/p&gt;

&lt;p&gt;Here is the task definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOAD_QUERY = '''COPY INTO &amp;lt;DATABASE_NAME&amp;gt;.&amp;lt;SCHEMA_NAME&amp;gt;.&amp;lt;TABLE_NAME&amp;gt; FROM @&amp;lt;DATABASE_NAME&amp;gt;.&amp;lt;SCHEMA_NAME&amp;gt;.&amp;lt;STAGE_NAME&amp;gt;/&amp;lt;FILE_NAME&amp;gt;.csv
file_format = (format_name = &amp;lt;DATABASE_NAME&amp;gt;.&amp;lt;SCHEMA_NAME&amp;gt;.FF_CSV)'''

load_task = SnowflakeOperator(
        task_id='LOAD_TASK',
        sql=[LOAD_QUERY],
        snowflake_conn_id='&amp;lt;connection_id&amp;gt;',
        database='&amp;lt;DATABASE_NAME&amp;gt;',
        schema='&amp;lt;SCHEMA_NAME&amp;gt;',
        warehouse = '&amp;lt;DATAWAREHOUSE_NAME&amp;gt;',
        role = '&amp;lt;ROLE_NAME&amp;gt;',
        dag=dag) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Providing Task Flow&lt;/strong&gt;&lt;br&gt;
At last, you have to bring all the tasks together in one liner. Use this code snippet at the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with dag:
  trunc_task &amp;gt;&amp;gt; unzip_task &amp;gt;&amp;gt; load_task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Upload and Run the DAG script&lt;/strong&gt;&lt;br&gt;
Now upload the DAG script you just created into GCS bucket attached to Composer environment bucket. Apache Airflow WebUI will automatically reflect the new DAG after few minutes and will start running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this article, we learnt how to load zip files stored in GCS bucket using Apache Airflow into Snowflake table. We also went through the creation and deployment of DAG in GCS Composer. For future discussions, we will explore other integration methods in Apache Airflow.&lt;/p&gt;

&lt;p&gt;Till then, Goodbye!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
