<?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: JayReddy</title>
    <description>The latest articles on DEV Community by JayReddy (@jayreddy).</description>
    <link>https://dev.to/jayreddy</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%2F575096%2F86b158b8-1e63-4fc2-8bda-c067a32ef317.png</url>
      <title>DEV Community: JayReddy</title>
      <link>https://dev.to/jayreddy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jayreddy"/>
    <language>en</language>
    <item>
      <title>Building a Monitoring dashboard with Kubernetes and Grafana.</title>
      <dc:creator>JayReddy</dc:creator>
      <pubDate>Fri, 23 Dec 2022 18:10:02 +0000</pubDate>
      <link>https://dev.to/jayreddy/building-a-monitoring-dashboard-with-kubernetes-and-grafana-503a</link>
      <guid>https://dev.to/jayreddy/building-a-monitoring-dashboard-with-kubernetes-and-grafana-503a</guid>
      <description>&lt;p&gt;Grafana and Prometheus are popular tools for visualizing and monitoring metrics in a Kubernetes cluster. By integrating Grafana with Prometheus, you can create dashboards and panels that display various metrics, including CPU and memory usage, network throughput, and more. This can help you identify performance issues, troubleshoot problems, and optimize the performance of your cluster.&lt;/p&gt;

&lt;p&gt;Here are some things you can do with Grafana and Prometheus to tune the performance of the Kubernetes cluster:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monitor resource usage:&lt;/strong&gt; By creating panels that display CPU, memory, and other resource usage metrics, you can identify which components of your cluster are consuming the most resources, and take steps to optimize their performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Analyze request latencies:&lt;/strong&gt; By creating panels that display request latencies and response times, you can identify bottlenecks in your cluster and take steps to improve performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identify spikes and anomalies:&lt;/strong&gt; By using Grafana’s anomaly detection features, you can identify unusual spikes or dips in your metrics, and investigate their root cause.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set alerts and notifications:&lt;/strong&gt; By setting up alerts and notifications in Grafana, you can be notified when certain thresholds are crossed, or when certain conditions are met, so you can take timely action to address performance issues.&lt;/p&gt;

&lt;p&gt;Integrating Kubernetes with Grafana needs RBAC roles and grafana installation on the Kubernetes cluster. Let’s tackle one problem at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Configure Grafana RBAC roles and permissions&lt;/strong&gt;&lt;br&gt;
Grafana provides Role-Based Access Control (RBAC) to control access to the various features and functions of the platform. In Grafana, users can be organized into organizations, and organizations can be assigned roles that define the level of access and permissions they have within the platform.&lt;/p&gt;

&lt;p&gt;To configure RBAC roles and permissions in Grafana, you will need to access the Grafana configuration file (usually located at /etc/grafana/grafana.ini) and the Grafana database.&lt;/p&gt;

&lt;p&gt;Here are the steps to configure RBAC roles and permissions in Grafana:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Locate the [auth.anonymous] the section in the Grafana configuration file and set the enabled option to true to enable anonymous access to Grafana. This will allow users to access Grafana without logging in.&lt;/li&gt;
&lt;li&gt;- In the [auth.anonymous] section, set the org_role option to the role you want anonymous users to have. For example, to give anonymous users the Viewer role, set org_role = Viewer.&lt;/li&gt;
&lt;li&gt;- In the [auth.ldap] section, set the enabled option to true to enable LDAP authentication. This will allow users to log in to Grafana using their LDAP credentials.&lt;/li&gt;
&lt;li&gt;- In the [auth.ldap] section, set the default_role option to the role you want to assign to LDAP users by default. For example, to give LDAP users the Editor role by default, set default_role = Editor.&lt;/li&gt;
&lt;li&gt;- In the [auth.ldap] section set the allow_sign_up option to true to allow users to sign up for Grafana using their LDAP credentials.&lt;/li&gt;
&lt;li&gt;- In the [auth.ldap] section, configure the LDAP server connection settings, including the server, bind_dn, and bind_password options.&lt;/li&gt;
&lt;li&gt;- In the [auth.ldap] section, configure the LDAP user search settings, including the search_filter, search_base_dns, and search_bind_dn options.&lt;/li&gt;
&lt;li&gt;- In the Grafana database, create a new organization and assign the desired roles to the organization.&lt;/li&gt;
&lt;li&gt;- In the Grafana database, create new users and assign them to the appropriate organization.&lt;/li&gt;
&lt;li&gt;- By configuring the RBAC roles and permissions in this way, you can control access to the various features and functions of Grafana based on the role and organization of each user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of the code you might use to configure RBAC roles and permissions in Grafana:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[auth.anonymous]
# Enable anonymous access
enabled = true
# Set the default role for anonymous users
org_role = Viewer
[auth.ldap]
# Enable LDAP authentication
enabled = true
# Set the default role for LDAP users
default_role = Editor
# Allow users to sign up for Grafana using their LDAP credentials
allow_sign_up = true
# Configure LDAP server connection settings
server = ldap://ldap.example.com
bind_dn = cn=admin,dc=example,dc=com
bind_password = password
# Configure LDAP user search settings
search_filter = (sAMAccountName=%s)
search_base_dns = dc=example,dc=com
search_bind_dn = cn=admin,dc=example,dc=com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a new organization and assign roles to it in the Grafana database, you can use SQL commands like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Create a new organization
INSERT INTO org (name) VALUES ('My Organization');
-- Get the ID of the new organization
SELECT id FROM org WHERE name = 'My Organization';
-- Assign the Viewer role to the organization
INSERT INTO org_role (org_id, role) VALUES (1, 'Viewer');
-- Assign the Editor role to the organization
INSERT INTO org_role (org_id, role) VALUES (1, 'Editor');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a new user and assign them to an organization in the Grafana database, you can use SQL commands like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Create a new user
INSERT INTO user (login, email, name) VALUES ('user1', 'user1@example.com', 'User 1');
-- Get the ID of the new user
SELECT id FROM user WHERE login = 'user1';-- Assign the user to the organization
INSERT INTO user_org (org_id, user_id, role) VALUES (1, 1, 'Viewer');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Kubernetes setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install and set up Grafana on a Kubernetes cluster, you can follow these steps:&lt;/p&gt;

&lt;p&gt;Deploy the Grafana Helm chart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana grafana/grafana
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that the Grafana pod is running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get pods -n default&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Forward the Grafana service to your local machine:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl port-forward service/grafana -n default 3000:3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Open your web browser and go to &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;. You should see the Grafana login page.&lt;/p&gt;

&lt;p&gt;Login with the default username and password (admin/admin).&lt;/p&gt;

&lt;p&gt;Click on the “Add data source” button and add your data source. Grafana supports a wide range of data sources, including Prometheus, InfluxDB, and more.&lt;/p&gt;

&lt;p&gt;Create a dashboard and add panels to display your metrics. You can use the query editor to customize the metrics that are displayed in each panel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Grafana setup&lt;/strong&gt;&lt;br&gt;
To set up Grafana on Kubernetes, you will need to create a Kubernetes deployment and service to run Grafana in a container. You will also need to set up persistent storage for Grafana to ensure that your data is preserved across restarts and failures.&lt;/p&gt;

&lt;p&gt;Here are the steps to set up Grafana on Kubernetes:&lt;/p&gt;

&lt;p&gt;Install the Kubernetes command-line tool kubectl and set up a connection to your Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;Create a configuration file for the Grafana deployment. This file should specify the container image for Grafana, the number of replicas to run, and any environment variables or volume mounts you need. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana-test
  labels:
    app: grafana-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grafana-test1
  template:
    metadata:
      labels:
        app: grafana-test1
    spec:
      containers:
      - name: grafana-test2
        image: grafana/grafana:7.4.5
        env:
        - name: GF_SECURITY_ADMIN_PASSWORD
          value: secret
        volumeMounts:
        - name: grafana-storage
          mountPath: /var/lib/grafana
      volumes:
      - name: grafana-storage
        persistentVolumeClaim:
          claimName: grafana-storage-claim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a configuration file for the Grafana service. This file should specify the type of service you want to create (e.g. ClusterIP, NodePort, LoadBalancer) and the port mapping for the Grafana container. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  name: grafana-test
  labels:
    app: grafana-test
spec:
  type: LoadBalancer
  ports:
  - port: 3000
    targetPort: 3000
  selector:
    app: grafana
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a persistent volume claim to provide persistent storage for Grafana. This will allow Grafana to store its data across restarts and failures.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-storage-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use kubectl to apply the deployment, service, and persistent volume claim configuration files to your Kubernetes cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f grafana-deployment.yaml
kubectl apply -f grafana-service.yaml
kubectl apply -f grafana-storage.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait for the Grafana pod to be up and running. You can use the following command to check the status of the pod:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get pods -l app=grafana-test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once the Grafana pod is running, you can access the Grafana web interface by visiting the service URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Grafana is a popular open-source data visualization and monitoring platform that can be used to monitor and visualize data from a variety of sources, including Kubernetes. Kubernetes is a container orchestration platform that can be used to deploy, manage and scale containerized applications.&lt;/p&gt;

&lt;p&gt;Building production-grade monitoring tools are very critical and building them efficiently is critical. This demo illustrates on how to integrate performant and advanced open-source tools and build monitoring services to track, isolate, remediate and mitigate enterprise-grade issues.&lt;/p&gt;

&lt;p&gt;Follow me for more….&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/jayachandra-sekhar-reddy/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/jayachandra-sekhar-reddy/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to handle nested JSON with Apache Spark</title>
      <dc:creator>JayReddy</dc:creator>
      <pubDate>Thu, 03 Feb 2022 08:28:00 +0000</pubDate>
      <link>https://dev.to/jayreddy/how-to-handle-nested-json-with-apache-spark-3okg</link>
      <guid>https://dev.to/jayreddy/how-to-handle-nested-json-with-apache-spark-3okg</guid>
      <description>&lt;p&gt;Learn how to convert a nested JSON file into a DataFrame/table&lt;/p&gt;

&lt;p&gt;Handling Semi-Structured data like JSON can be challenging sometimes, especially when dealing with web responses where we get HTTP responses in JSON format or when a client decides to transfer the data in JSON format to achieve optimal performance by marshaling data over the wire.&lt;/p&gt;

&lt;p&gt;The business requirement might demand the incoming JSON data to be stored in tabular format for efficient querying.&lt;/p&gt;

&lt;p&gt;This blog post is intended to demonstrate how to flatten JSON to tabular data and save it in desired file format.&lt;/p&gt;

&lt;p&gt;This use-case can also be solved by using the JOLT tool that has some advanced features to handle JSON.&lt;/p&gt;

&lt;p&gt;Let's start digging by importing the required packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Required imports:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.spark.sql.functions.col
import org.apache.spark.sql.types.{ArrayType, StructType}
import scala.io.Source
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample nested JSON file,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val nestedJSON ="""{
                   "Total_value": 3,
                   "Topic": "Example",
                   "values": [
                              {
                                "value1": "#example1",
                                "points": [
                                           [
                                           "123",
                                           "156"
                                          ]
                                    ],
                                "properties": {
                                 "date": "12-04-19",
                                 "model": "Model example 1"
                                    }
                                 },
                               {"value2": "#example2",
                                "points": [
                                           [
                                           "124",
                                           "157"
                                          ]
                                    ],
                                "properties": {
                                 "date": "12-05-19",
                                 "model": "Model example 2"
                                    }
                                 }
                              ]
                       }"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;step 1:&lt;/strong&gt; Read inline JSON file as &lt;code&gt;Dataframe&lt;/code&gt; to perform transformations on the input data.&lt;/p&gt;

&lt;p&gt;we are using the sparks &lt;code&gt;createDataset&lt;/code&gt; method to read the data with tight dependency on the schema.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Dataset&lt;/code&gt; is a strongly typed collection of objects that are domain-specific, datasets offer the flexibility to transform the domain-specific objects in parallel using functional operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val flattenDF = spark.read.json(spark.createDataset(nestedJSON :: Nil))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;step 2:&lt;/strong&gt; read the DataFrame fields through schema and extract field names by mapping over the fields,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val fields = df.schema.fields
val fieldNames = fields.map(x =&amp;gt; x.name)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;step 3:&lt;/strong&gt; iterate over field indices to get all values and types, and explode the JSON file. Run pattern matching to output our data.&lt;/p&gt;

&lt;p&gt;we explode columns based on data types like ArrayType or StructType.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (i &amp;lt;- fields.indices) {
        val field = fields(i)
        val fieldName = field.name       
        val fieldtype = field.dataType
        fieldtype match {
          case aType: ArrayType =&amp;gt;
            val firstFieldName = fieldName
            val fieldNamesExcludingArrayType = fieldNames.filter(_ != firstFieldName)
            val explodeFieldNames = fieldNamesExcludingArrayType ++ Array(s"explode_outer($firstFieldName) as $firstFieldName")
            val explodedDf = df.selectExpr(explodeFieldNames: _*)
            return flattenDataframe(explodedDf)

          case sType: StructType =&amp;gt;
            val childFieldnames = sType.fieldNames.map(childname =&amp;gt; fieldName + "." + childname)
            val newfieldNames = fieldNames.filter(_ != fieldName) ++ childFieldnames
            val renamedcols = newfieldNames.map(x =&amp;gt; (col(x.toString()).as(x.toString().replace(".", "_").replace("$", "_").replace("__", "_").replace(" ", "").replace("-", ""))))
            val explodedf = df.select(renamedcols: _*)
            return flattenDataframe(explodedf)
          case _ =&amp;gt;
        }
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complete Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;object json_to_scala_faltten {

  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().appName("json-to-parquet").master("local[4]").getOrCreate()

    import spark.implicits._

    val flattenDF = spark.read.json(spark.createDataset(nestedJSON :: Nil))
    def flattenDF(df: DataFrame): DataFrame = {
      val fields = df.schema.fields
      val fieldNames = fields.map(x =&amp;gt; x.name)
      for (i &amp;lt;- fields.indices) {
        val field = fields(i)
        val fieldtype = field.dataType
        val fieldName = field.name
        fieldtype match {
          case aType: ArrayType =&amp;gt;
            val firstFieldName = fieldName
            val fieldNamesExcludingArrayType = fieldNames.filter(_ != firstFieldName)
            val explodeFieldNames = fieldNamesExcludingArrayType ++ Array(s"explode_outer($firstFieldName) as $firstFieldName")
            val explodedDf = df.selectExpr(explodeFieldNames: _*)
            return flattenDF(explodedDf)

          case sType: StructType =&amp;gt;
            val childFieldnames = sType.fieldNames.map(childname =&amp;gt; fieldName + "." + childname)
            val newfieldNames = fieldNames.filter(_ != fieldName) ++ childFieldnames
            val renamedcols = newfieldNames.map(x =&amp;gt; (col(x.toString()).as(x.toString().replace(".", "_").replace("$", "_").replace("__", "_").replace(" ", "").replace("-", ""))))
            val explodedf = df.select(renamedcols: _*)
            return flattenDF(explodedf)
          case _ =&amp;gt;
        }
      }
      df
    }
val FDF = flattenDataframe(flattenDF)
FDF.show()
FDF.write.format("formatType").save("/path/filename")
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D9uEnyX4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as8i8mz51rco0nps3yrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D9uEnyX4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as8i8mz51rco0nps3yrh.png" alt="Output Data" width="880" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Semi-Structured Data is challenging to work with when you are getting the data in nested form. Hopefully, this post gives you an overview of how to perform a simple ETL on JSON data. You can make modifications to the logic and find out more about how to get the desired results.&lt;br&gt;
References:&lt;br&gt;
&lt;a href="https://github.com/bazaarvoice/jolt/releases"&gt;https://github.com/bazaarvoice/jolt/releases&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://spark.apache.org/docs/latest/sql-data-sources-json.html"&gt;https://spark.apache.org/docs/latest/sql-data-sources-json.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>bigdata</category>
      <category>spark</category>
      <category>scala</category>
    </item>
    <item>
      <title>A curated list on Data Engineering</title>
      <dc:creator>JayReddy</dc:creator>
      <pubDate>Tue, 01 Feb 2022 08:09:24 +0000</pubDate>
      <link>https://dev.to/jayreddy/a-curated-list-on-data-engineering-2i7</link>
      <guid>https://dev.to/jayreddy/a-curated-list-on-data-engineering-2i7</guid>
      <description>&lt;p&gt;Catch up on the trending articles from Data Engineering Space.&lt;/p&gt;

&lt;p&gt;A curated list of the most engaging blog posts will be shared here and a newsletter will be sent out to keep the readers up-to-date with the world of Data Engineering.&lt;/p&gt;

&lt;p&gt;Data is the epicenter of the Digital world. Every byte of data has a story to tell.&lt;/p&gt;

&lt;p&gt;The True business value lies in a well-narrated story. To achieve this, data engineers should pre-plan, design, develop and deploy data pipelines carefully.&lt;/p&gt;

&lt;p&gt;Companies collect and analyze vast amounts of data as their success and growth depend on it.&lt;/p&gt;

&lt;p&gt;Only 30% of the data is deriving meaningful insights. The rest of it is being mounted unproductively on a remote storage device. We can only leverage the true value of these datasets when they are well arranged and streamlined for accessibility and ease of use.&lt;/p&gt;

&lt;p&gt;Handling and managing data is not as easy as it sounds. With the efficient design, the system can derive valuable insights.&lt;/p&gt;

&lt;p&gt;Data Engineering to the rescue.&lt;/p&gt;

&lt;p&gt;Data Engineering is a brilliant and rewarding approach to get maximum value out of your data by carefully organizing, curating, and streamlining the data end-to-end.&lt;/p&gt;

&lt;p&gt;Data Engineering has a lot to offer towards achieving data-centric business requirements. Companies are adapting Data Engineering excessively and focusing on implementing it in every business use case to make the data speak.&lt;/p&gt;

&lt;p&gt;A good start to know how rewarding Data Engineering is to refer to what the Experts in the Data field are predicting about the data trends and how the future will be. this post might change your overall perspective of the field,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/coriers/5-big-data-experts-predictions-for-2022-a333111299ed"&gt;5 Big Data Experts Predictions For 2022&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thoughts and Opinions in the blog post are from the Data startup founders and Data Engineers contributing to fast-paced Data-Centric companies.&lt;/p&gt;

&lt;p&gt;It’s hard to predict which technologies will leave their mark in the Data sector and which ones will become a part of history.&lt;/p&gt;

&lt;p&gt;Adding new features to cope with challenging and changing businesses will make the technologies adapt and grow. Experts highlight which technologies are achieving this and how they will be contributing to the greater good.&lt;/p&gt;

&lt;p&gt;It must be well established by now about how important Data Engineering will be for companies.&lt;/p&gt;

&lt;p&gt;Our next post is about how teams can leverage cloud technologies for collaboration and productivity.&lt;/p&gt;

&lt;p&gt;SQL- the de facto standard data querying language. Most business operations that are data-centric heavily rely on general SQL querying.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/aws-builders/how-to-share-sql-queries-in-amazon-redshift-with-your-team-6lh"&gt;How to share SQL queries in Amazon Redshift with your team&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post explains how remote teams can share work over the cloud with team members and how the tasks can be fulfilled by delegating the work.&lt;/p&gt;

&lt;p&gt;The content is about Amazon Redshift, a Cloud Data Warehouse, and SQL, with hands-on illustration that is well structured.&lt;/p&gt;

&lt;p&gt;Reading and writing data is achieved with simple SQL queries for a long time. Data querying was a crucial and integral part of the business when the main focus was descriptive analytics(generating reports).&lt;/p&gt;

&lt;p&gt;Over time business requirements extended to fulfill challenging business requirements data needed to be curated and aggregated to a final agreed-upon version. This final version can be utilized for analytics by Business Intelligence teams.&lt;/p&gt;

&lt;p&gt;We can derive meaningful insights by applying advanced transformations to the datasets.&lt;/p&gt;

&lt;p&gt;Data transformation is a must and heavily applied operation in any ETL, ELT job, and is implemented in almost all business use cases ranging from very simple to high-level projects.&lt;/p&gt;

&lt;p&gt;When considering cost and performance, business requirements demand different strategies.&lt;/p&gt;

&lt;p&gt;Data Transformation happens at two stages in a Data Pipeline, before and after loading to reliable storage. Former is when we extract the data from the source, transform and load it to the destination(ETL), while in the latter we extract data from the source, load it to the destination and then perform transformations on the destination datasets(ELT).&lt;/p&gt;

&lt;p&gt;ETL strategy can be optimal to transform small datasets in memory.&lt;/p&gt;

&lt;p&gt;When the dataset is large, applying transformation in-memory is no longer a viable option as it requires spinning up many master and worker nodes in the cloud. This approach can be time-consuming and results in outcomes with high latency by affecting the cost to compute.&lt;/p&gt;

&lt;p&gt;ELT can be very rewarding when the requirement is to apply transformations on large datasets to reduce operational costs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/zompro/extract-csv-data-and-load-it-to-postgresql-using-meltano-elt-4ipf"&gt;Extract csv data and load it to PostgreSQL using Meltano ELT&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog post, you will learn how to perform ELT with an exciting DataOps Framework “Meltano” and work on PostgreSQL, a high-demand relational SQL language with python.&lt;/p&gt;

&lt;p&gt;It just doesn’t stop there. Data Engineering is not just extracting data, transforming for meaningful insights, and loading it to a reliable storage unit.&lt;/p&gt;

&lt;p&gt;We have to bring together multiple pieces of the puzzle to make the data journey possible. one piece is designing data pipelines for the data movement from source to destination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/tkeyo/data-engineering-pipeline-with-aws-step-functions-codebuild-and-dagster-5290"&gt;Data Engineering Pipeline with AWS Step Functions, CodeBuild and Dagster&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This blog post explains how an end-to-end data pipeline is built to collect, process, and visualize data on the cloud.&lt;/p&gt;

&lt;p&gt;A workflow is a unit of work that has a sequence of actions.&lt;/p&gt;

&lt;p&gt;A workflow is designed to function in a repeatable fashion, triggered by a pre-defined schedule or events.&lt;/p&gt;

&lt;p&gt;After a workflow is triggered, each action in the workflow needs monitoring. Monitoring should be set up and configured to store the state of every single workflow action in the form of logs for each pipeline run.&lt;/p&gt;

&lt;p&gt;The operations team will be alerted if any action fails to implement corrective actions. Dagster is a workflow management platform similar to airflow, which orchestrates your Data Engineering tasks for machine learning, analytics, ETL and comes with an event scheduler that handles failures during unlikely events and helps in monitoring the state by sending out notifications and logs to the team.&lt;/p&gt;

&lt;p&gt;AWS Step Functions is a low-code, visual workflow service designed to build distributed applications by automating IT and business processes and building data + machine learning pipelines.&lt;/p&gt;

&lt;p&gt;Distributed applications are suitable for delivering performance boosts and resilience to the overall system and are in high demand.&lt;/p&gt;

&lt;p&gt;Here, you get to learn how to write distributed applications for parallel processing and high performance on the cloud using AWS step Functions.&lt;/p&gt;

&lt;p&gt;Handling data variety often seems a challenging endeavor. Data today comes in different types and formats that can be stored and used according to business requirements. When I say storage, that doesn’t just mean a traditional database. Data storage comes in different shapes and sizes, from on-premise enterprise storage to cloud storage.&lt;/p&gt;

&lt;p&gt;Depending on the type, data lakes are viable for storing unstructured data and are suitable for Data science-related tasks.&lt;/p&gt;

&lt;p&gt;Data warehouses are for structured and semi-structured data. Data Warehouses stores data from ETL jobs and are used for analytics by Business Intelligence teams to derive meaningful business insights.&lt;/p&gt;

&lt;p&gt;Cloud data lakes are in high demand. Delta sharing is one of a kind Azure service to manage and handle your data lakes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@wahidatoui/azure-synapse-how-to-use-delta-sharing-f9f76e5083b7"&gt;Azure Synapse — How to use Delta Sharing?&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog post, you will learn about Delta sharing and how to use it for your business needs.&lt;/p&gt;

&lt;p&gt;Delta sharing is a limitless analytics service designed to bring together enterprise data warehousing and Big Data analytics.&lt;/p&gt;

&lt;p&gt;Automation is one of the must-implement features if the workflow has repetitive tasks to minimize resource utilization.&lt;/p&gt;

&lt;p&gt;In Data Pipelines, one of the most common tasks is data movement from source to destination. The same operations get applied for different use cases.&lt;/p&gt;

&lt;p&gt;Snowflake is a Trending and Popular Cloud Data warehouse offering easy to store and process data interface. Snowflake provides integrations of tens of different libraries and languages to expand your business use cases based on underlying technologies. Amazon Simple Storage Service(S3) is the most popular and excessively adapted cloud object storage in the market.&lt;/p&gt;

&lt;p&gt;Knowing how to use and implement Snowflake to automate the data movement can be an immense advantage to your business.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://selectfrom.dev/automating-data-movement-from-snowflake-to-s3-b280b1ca7f28"&gt;Automating Data Movement from Snowflake to S3&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post might be a good start for you to learn how to automate your data flows from the cloud data warehouse to reliable cloud storage.&lt;/p&gt;

&lt;p&gt;Opinions are my own. Please leave a comment.&lt;/p&gt;

&lt;p&gt;Until next time.&lt;/p&gt;

&lt;p&gt;Subscribe to my newsletter to stay up to date on the Data Engineering content. &lt;a href="https://lambdaverse.substack.com/"&gt;Lambdaverse&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Quill- Most efficient Scala driver for Apache Cassandra and Spark</title>
      <dc:creator>JayReddy</dc:creator>
      <pubDate>Mon, 31 Jan 2022 18:31:43 +0000</pubDate>
      <link>https://dev.to/jayreddy/quill-most-efficient-scala-driver-for-apache-cassandra-and-spark-1gfj</link>
      <guid>https://dev.to/jayreddy/quill-most-efficient-scala-driver-for-apache-cassandra-and-spark-1gfj</guid>
      <description>&lt;p&gt;Apache Cassandra is an open-source, distributed data storage system that is durable, scalable, consistently tuneable, and is highly efficient for OLAP.&lt;/p&gt;

&lt;p&gt;It was 2009, Cassandra first started as an Incubator project at Apache, Shortly thereafter Apache Cassandra gained a lot of traction and grew to what we see today. Cassandra has an active community of enthusiastic developers and is being used in production by many big companies on the web. to name a few Facebook, Twitter, and Netflix.&lt;/p&gt;

&lt;p&gt;Apache Cassandra operates blazingly fast when compared to RDBMS for database writes and can store hundreds of terabytes of data in a decentralized and symmetrical way with no single point of failure.&lt;/p&gt;

&lt;p&gt;Quill is a Scala library that provides a Quoted Domain Specific Language to express queries in Scala and execute them in a target language.&lt;/p&gt;

&lt;p&gt;Quill and Cassandra are a perfect match to query, run and optimize unstructured data in Apache spark offering exceptional capabilities to work with No-SQL distributed databases.&lt;/p&gt;

&lt;p&gt;Cassandra can be integrated with apache Spark using a docker image or by using a jar file. Let's go with the docker image approach as we might want to experiment with Cassandra shell(CSH) and Cassandra Query Language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt;&lt;br&gt;
Let's spin up the Apache Cassandra node on Docker,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3"
services
Cassandra:
    image: cassandra:latest
    volumes: ["./cassandra/cassandra.yml:/etc/cassandra/cassandra.yml"]
    ports: ["9042:9042"]
    networks: ["sandbox"]
networks:
sandbox:
    driver: bridge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will use Apache Spark’s recent release is 3.2.0 as a shell with a connector and Cassandra’s client library 3.11 and pass the scala jar file as a parameter to run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./spark-shell — packages com.datastax.spark:spark-cassandra-connector_2.12:3.2.0-beta,com.datastax.cassandra:cassandra-driver-core:3.11 spark-cassandra-connector-assembly-1.1.1-SNAPSHOT.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apache Cassandra has a dedicated shell that is more like Scala’s REPL called cqlsh for running CQL scripts.&lt;/p&gt;

&lt;p&gt;to start cqlsh we need to execute our container image,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo docker exec -it container_name cqlsh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;First, we have to create a keyspace, which is like a container where our tables will be residing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE KEYSPACE spark_playground WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the CSH and KEYSPACE is in place, we can run any Cassandra query and write it to file using Sparks write method,&lt;/p&gt;

&lt;p&gt;Let's get to the main focus of the article now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spark Integration with Quill&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Quill shines in offering a fully type-safe library to use Spark’s highly-optimized SQL engine.&lt;/p&gt;

&lt;p&gt;Let's see how Quill works,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Simple case classes are used for mapping the database schema.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“Quoted DSL” — Quill leverages the mechanism of quote block in which Queries are defined. Quill parses each quoted block of code at compile time with the help of Scala’s &lt;br&gt;
powerful compiler and translates the queries into an internal Abstract Syntax Tree (AST). similar to Sparks dags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compile-time query generation: The ctx.run is responsible for reading the AST which is generated in step 2 and translates to the target language at compile-time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compile-time query validation: upon configuration, the query is verified against the database schema at compile-time. compilation status depends on the configuration. The query validation step does not alter the database state.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's Import quill-spark dependency into your sbt and build the project for usage.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libraryDependencies ++= Seq(
  "io.getquill" %% "quill-spark" % "3.16.1-SNAPSHOT"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's create a Spark session and import the required packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.apache.spark.sql.{SparkSession, sqlContext}
val spark =
  SparkSession.builder()
    .master("local")
    .appName("spark-quill-test")
    .getOrCreate()
// The Spark SQL Context must be provided by the user through an implicit value:
implicit val sqlContext = spark.sqlContext
import spark.implicits._
// Import the Quill Spark Context
import io.getquill.QuillSparkContext._
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note Unlike the other modules, the Spark context is a companion object. Also, it does not depend on a spark session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Quill-Spark:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The run method returns a Dataset transformed by the Quill query using the SQL engine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Typically you start with some type dataset.
val data: Dataset[Data] = spark.read.format("csv").option("header", "true").load("/home/lambdaverse/spark_and_cassandra/test_data.csv")
// The liftQuery method converts Datasets to Quill queries:
val data: Query[Data] = quote { liftQuery(data) }
val data: Query[(Data] = quote {
  data.join(addresses).on((p, a) =&amp;gt; p.fact == a.dim)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is an example of a Dataset being converted into Quill, filtered, and then written back out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.apache.spark.sql.Dataset
def filter(myDataset: Dataset[Data], name: String): Dataset[Int] =
  run {
    liftQuery(myDataset).filter(_.fact == lift(fact)).map(_.dim)
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Apache Spark is a popular big Data Analytical engine used in many fortune 500 companies.&lt;/p&gt;

&lt;p&gt;Apache spark is known for its ability to process Structured and Un-Structured data. almost 70% of the data that is being generated today is Unstructured.&lt;/p&gt;

&lt;p&gt;Cassandra is written in JAVA offering exceptional features and is a modern data stack, Quill is a Scala library that supports Cassandra integration.&lt;/p&gt;

&lt;p&gt;This post is purely meant for educational purposes and opinions and content is referred from the official Quill page for better elaboration.&lt;/p&gt;

&lt;p&gt;Please clap if you like the post and support.&lt;br&gt;
subscribe to my newsletter to stay up to date on the Data Engineering content. [&lt;a href="https://lambdaverse.substack.com/"&gt;https://lambdaverse.substack.com/&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>bigdata</category>
      <category>spark</category>
      <category>sql</category>
      <category>database</category>
    </item>
  </channel>
</rss>
