<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ivelina Yordanova on Medium]]></title>
        <description><![CDATA[Stories by Ivelina Yordanova on Medium]]></description>
        <link>https://medium.com/@ivs.yordanova?source=rss-97cfe701f78------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*n9z0gv946YjSHPpiy_U-zg.jpeg</url>
            <title>Stories by Ivelina Yordanova on Medium</title>
            <link>https://medium.com/@ivs.yordanova?source=rss-97cfe701f78------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:51:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ivs.yordanova/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making sense of your data]]></title>
            <link>https://blog.devgenius.io/making-sense-of-your-data-71e873ef4e65?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/71e873ef4e65</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-tracking]]></category>
            <category><![CDATA[data-catalog]]></category>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[schema]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sun, 08 Sep 2024 12:35:20 GMT</pubDate>
            <atom:updated>2024-09-23T10:52:51.924Z</atom:updated>
            <content:encoded><![CDATA[<h3>Schemas, lineage, tracing and catalog</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PeBCn4Z6GGqciGpz" /><figcaption>Photo by <a href="https://unsplash.com/@kommumikation?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Collecting data for the sake of having data is pointless ..and most likely a regulatory issue. To be able to use the data, an organization needs to be able to make sense of it — to know what‘s available, how to interpret it, where it comes from, how it flows through the system, what transformations are applied and finally where it gets to.</p><p>The way to gain visibility over those different aspects is by using <strong>schemas, data lineage, traceability and cataloguing </strong>tools. The purpose of each of these overlaps with the next and many products provide ways to do most of all in a single solution.</p><p>However, there are nuances in the problem each solves and the ways it can be used. What’s more, most proprietary products usually have their own custom way of approaching a task and it’s hard to mix and match solutions fitting your goal, so we’ll look at some standards and tools supporting those.</p><p>First thing’s first — what’s the problem each of the above-mentioned principles and tools.</p><h3>Data Schemas Types and..Why?</h3><p>Schemas are primarily a contract between producers and consumers of the data, which helps develop more robust products at each level. They define the data structure and facilitate communication between users of technical and non-technical background. Schemas can be defined for the stored data as well as the data across every stage of the pipeline if passes through.</p><h4>Relational Database Schemas</h4><p>Relational databases require an explicit design to be in place before one even begins to use them. Data model needs to be defined, outlining table and column names, data types and the relationships between all the entities. The schemas can be visually represented and help provide alignment between various stakeholders and users — admins, engineers, analysts and the business.</p><p>There are 3 types of database schemas:</p><ul><li><strong>conceptual</strong> schemas — high-level view of what the DB would contain, usually created in the initial discovery stages</li><li><strong>logical</strong> schemas — defines schema entities with their fields, types, relationships and constraints</li><li><strong>physical</strong> schemas — includes any technical requirements that the logical database schema lacks — table and column names, data types, keys etc., it’s the actual syntax that will be used to create the schemas</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcc56X8rbNroa9U9lbZ57A.png" /><figcaption>Source: <a href="https://www.thoughtspot.com/data-trends/data-modeling/database-schema">https://www.thoughtspot.com/data-trends/data-modeling/database-schema</a></figcaption></figure><p>While those 3 database schema types represent the different level of details you can have in a schema at different stages of development, there are additional types that describe the data model itself:</p><ul><li><strong>flat</strong> — a single simple, two-dimensional store — like Microsoft Excel spreadsheet or a CSV file.</li><li><strong>hierarchical — </strong>tree-like structure, with child entities branching out from a root</li><li><strong>network — </strong>treats data as entities connected to one other in more complex ways — many-to-many relationships and cycles</li><li><strong>relational</strong> — organizes data in a series of tables, rows, and columns, creating relationships between different entities</li><li><strong>star</strong> — a simper model where a single, central table is surrounded by multiple dimension tables</li><li><strong>snowflake</strong> —a single table surrounded by multiple dimension tables, which can also be connected to other dimension tables</li></ul><h4>NoSQL Databases Schemas</h4><p>NoSQL databases provide <strong>flexible schemas</strong> with the goal to speed up development with semi-structured or unstructured data. They offer a variety of data models — key-value, document, graph, and column.</p><p>Notice it’s “flexible schemas”, not “no schemas”. The data still needs to be modelled, so that it can be accessed in an efficient way. The difference with relational databases is that the latter has been standardised to a great degree and there are rules for optimising it with precision, while the former requires analysis on a per use case basis. The same set of data being used in 2 different ways could be modelled in 2 different ways to optimally serve those use cases.</p><p>In NoSQL world this most likely means developers need to make decisions like:</p><ul><li>whether to embed an entity into another or keep it separate — generally, unless there is a good reason not to, it’s recommended to try to keep all data accessible together and often as one single entity</li><li>to join or not to join — a variation of the previous point but worth mentioning — joins are generally to be avoided, but if it makes sense for the use case to use them, don’t try and come up with a potentially worst workaround</li><li>how to avoid hitting any of the db hard constraints — every DB has a size limit on different levels, for example: MongoDB has a limit of 16MB per document, DynamoDB has a 400 KB limit on each item in a table, Redis limits it’s values to 512MB</li></ul><p>Here’s a good <strong>example or converting a RDBMS schema to a MongoDB document model</strong> <a href="https://www.mongodb.com/developer/products/mongodb/modernizing-rdbms-schemas-mongodb-document/">https://www.mongodb.com/developer/products/mongodb/modernizing-rdbms-schemas-mongodb-document/</a></p><h4>Event Streaming Schemas</h4><p>In addition to having schemas for data at rest, organizations can (and probably should) choose to use schemas for their streaming data. This can both serve as a contract between producers and consumers, and ensure the data flow can be understood, tracked, governed and visualised effectively.</p><p>Kafka is one of the most popular ways to stream data and every distribution now provides ways to define and enforce event schemas through a schema registry. The schema itself can be defined in an AVRO, JSON or Protobuf format but the actual implementation of how that’s schema is enforced differ:</p><ul><li>Confluent’s own <a href="https://docs.confluent.io/platform/current/schema-registry/index.html">Schema Registry</a> — the ID of the schema for the message is sent with the message itself, encoded in the first few bytes as follows:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xIoePhtfYGfU_6eISKDpA.png" /><figcaption>More details on <a href="https://docs.confluent.io/cloud/current/sr/fundamentals/serdes-develop/index.html">https://docs.confluent.io/cloud/current/sr/fundamentals/serdes-develop/index.html</a></figcaption></figure><ul><li>AWS’s MSK can integrate with <a href="https://docs.aws.amazon.com/glue/latest/dg/schema-registry-integrations.html">AWS Glue’s Schema Registry</a> — similarly, the schema and the version are sent with the message, using some of the first bytes:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98HcWLLq2wMDEWrjefgctA.png" /><figcaption>More details on <a href="https://docs.aws.amazon.com/glue/latest/dg/schema-registry-works.html">https://docs.aws.amazon.com/glue/latest/dg/schema-registry-works.html</a></figcaption></figure><p>Once schemas are in place and we can clearly see what data is being processed or stored at each step, we can move using them to add real value to the business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGIo5PvRd5icKENLHbbaPg.png" /><figcaption>source : <a href="https://www.youtube.com/watch?v=MoW-YGjHLgI">https://www.youtube.com/watch?v=MoW-YGjHLgI</a></figcaption></figure><h4>Data Catalog</h4><p>A data catalog serves like a inventory of all the data that an organization collects and processes. It does that by collecting metadata about 3 different types of context:</p><ul><li><strong>business</strong> — descriptions, comments, annotations, classifications, quality, regulatory compliance details and more</li><li><strong>technical</strong> — schemas, tables, columns, file names, report names and its relationships to other sets</li><li><strong>operational</strong> — the data source, update cadence (freshness), access logs, transformation jobs applying changes to the source schema</li></ul><p>Good solutions should provide these capabilities:</p><ul><li><strong>automatic updates</strong> — it should not be a static snapshot of the data or require a manual input, it should be able to pick up changes automatically</li><li><strong>data discovery</strong> — it should allow searching data based on complex queries and filtering on parameters like source, type, owner, keyword or tag</li><li><strong>data lineage</strong> — provides a visual representation of the data’s lifecycle (more on this below)</li><li><strong>data classification and tagging — </strong>based on various attributes like source, sensitivity and business function. This is done manually but increasingly tools offer some ML algorithms that can do that automatically as well.g.</li><li><strong>data quality</strong> — with indicators such as freshness, completeness, uniqueness, validity, and more users can assess the usability of a particular dataset or detect issues when those start degrading.</li><li><strong>knowledge sharing</strong> — users with various roles in the business can contribute their knowledge about the data by adding comments, glossary entries, ratings and reviews. T collaborative effort would not only enhance the understanding but also build trust in the data</li><li><strong>governance, security, compliance </strong>— access control only to authorized users, audit logs, lineage and more</li></ul><p>Some popular tools for this are:</p><p>Proprietary:</p><ul><li><a href="https://aws.amazon.com/glue/">AWS Glue Data Catalog</a></li><li><a href="https://www.ibm.com/products/knowledge-catalog">IBM Knowledge Catalog</a></li><li><a href="https://cloud.google.com/data-catalog/docs/concepts/overview">Google’s Dataplex Data Catalog</a></li><li><a href="https://azure.microsoft.com/en-us/products/data-catalog/">Azure’s Data Catalog</a></li></ul><p>Open Source</p><ul><li><a href="https://atlan.com/?ref=/data-catalog-vs-data-lineage/">Atlan</a></li><li><a href="https://www.castordoc.com/">CastorDoc</a></li><li><a href="https://datahubproject.io/">DataHub</a></li><li><a href="https://open-metadata.org/">OpenMetadata</a></li><li><a href="https://marquezproject.ai/">Marquez</a></li><li><a href="https://www.amundsen.io/amundsen/">Amundsen</a></li><li><a href="https://atlas.apache.org/#/">Apache Atlas</a></li><li><a href="https://opendatadiscovery.org/">OpenDataDiscovery</a></li></ul><h4>Data Lineage</h4><p>I mentioned data lineage as a feature of the data catalog and it can be, but it’s a topic that deserves being discussed on its own.</p><p>Data lineage is a way to track the lifecycle of the data as well as the evolution of the changes applied over time. There are 2 levels of lineage — table-level and column-level.</p><p>Along with the impact it can have on governance by demonstrating the data flow, tracking data quality and PII field propagation, it can also add value on multiple other levels for the business. It’s a great way to understand interdependencies between processing jobs, services and team, which would help planning new feature development or debugging a production issue.</p><p>It can serve as an automatically updating itself and ever evolving documentation of the current state of all data pipelines in an organization, which would reduce onboarding time and help with collaboration by providing a single source of truth for detailed knowledge on how the data flows in a company.</p><p>A standard for collection and analytics of data lineage is being developed by the <a href="https://lfaidata.foundation/projects/openlineage/">Linux AI&amp;Data foundation</a> — <a href="https://openlineage.io/"><strong>OpenLineage</strong></a>. It defines a data model consisting of datasets, jobs, and runs.<a href="https://github.com/MarquezProject/marquez"> Marquez</a> is being developed in parallel as a reference implementation of a visualization and search tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkYiwMZ3xz5axlsxrn7UFA.png" /><figcaption>Source: <a href="https://openlineage.io/docs/next/#core-model">https://openlineage.io/docs/next/#core-model</a></figcaption></figure><p>It’s defines a <a href="https://github.com/OpenLineage/OpenLineage/blob/main/spec/OpenLineage.json">json schema</a> describing what metadata can be collected. It’s integrated with several systems:</p><ul><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/airflow">Apache Airflow</a></li><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/flink">Apache Flink</a></li><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/spark">Apache Spark</a></li><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/dagster">Dagster</a></li><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/dbt">dbt</a></li><li><a href="https://github.com/OpenLineage/OpenLineage/tree/main/integration/sql">SQL</a></li></ul><p>In addition to that there are Client Libraries in Python and Java which allow producers to send events to a tools, supporting OpenLineage through a REST api or Kafka.</p><p>Some tools like Apache Atlas, Spline, OpenMetadata and Marquez support OpenLineage.</p><p>The standard was initially focused on batch processing but as of this year it has support for Flink and it’s supposed to release integration with Kafka soon.</p><h3><strong>Event Tracing</strong></h3><p>Event tracing is not the same as data lineage.</p><p>While data lineage illustrates how the data flows and changes on a high level by looking at schemas, event tracing helps monitor and debug the flow of individual requests or events as they traverse through various components and services.</p><p>It requires applications to generate trace data, which contains details about the path and timing of events/requests as they flow through different services.</p><p>The main goals of event tracing is to monitor performance and identify bottlenecks, latency issues, errors in processing.</p><p><a href="https://opentelemetry.io/">OpenTelemetry</a> is the industry standard used for event tracing. Similar to OpenLineage it defines a model for metadata collection that’s vendor- and tool-agnostic.</p><p><a href="https://opentelemetry.io/docs/specs/otel/overview/">The model includes</a>:</p><ul><li><strong>traces</strong> —a single logical operation that can be distributed across multiple processes. It’s implicitly defined by the spans it contains — a trace can be thought of as a directed acyclic graph (DAG) of Spans</li><li><strong>spans</strong> — represents an operation within a transaction. Each Span has a name, start and end timestamp, a list of attributes, 0 or more events, parent span ID, links to 0 or more causally-related spans and SpanContext</li><li><strong>span context</strong> — all the information that identifies a span in the trace and must be propagated to child spans and across process boundaries such as traceId, spanId, traceFlags, sampling bit, tracestate carries tracing-system specific context in a list of key value pairs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXp1pT2rweLe1Iw8D7kfmg.png" /><figcaption>Source: <a href="https://docs.logz.io/docs/user-guide/distributed-tracing/tracing-overview/what-tracing/">https://docs.logz.io/docs/user-guide/distributed-tracing/tracing-overview/what-tracing/</a></figcaption></figure><p>Tools for collecting and visualizing tracing information:</p><p>OpenSource:</p><ul><li><a href="https://www.jaegertracing.io/">Jaeger</a></li><li><a href="https://prometheus.io/">Prometheus</a></li></ul><p>Commercial:</p><ul><li><a href="https://www.datadoghq.com/">DataDog</a></li><li><a href="https://www.dynatrace.com/">Dynatrace</a></li></ul><p>OpenTelemetry provides APIs and SDKs in a wide range of languages <a href="https://opentelemetry.io/docs/languages/">https://opentelemetry.io/docs/languages/</a>.</p><h4>Data Traceability</h4><p>In contrast to lineage and tracing, traceability is all about providing the ability to verify accuracy, quality and reliability of the data, to prove it has not been tampered with and can be traced back to the source. Therefore, it is particularly crucial for organizations that handle sensitive information. A traceability typically relies on unique identifiers, barcodes, or RFID tags.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71e873ef4e65" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/making-sense-of-your-data-71e873ef4e65">Making sense of your data</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON to JSON transformation with a template — engine comparison]]></title>
            <link>https://towardsdev.com/json-to-json-transformation-with-a-template-engine-comparison-d5d394a9ee3b?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5d394a9ee3b</guid>
            <category><![CDATA[freemarker]]></category>
            <category><![CDATA[transformation]]></category>
            <category><![CDATA[velocity]]></category>
            <category><![CDATA[jinja2]]></category>
            <category><![CDATA[jslt]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sun, 18 Aug 2024 21:08:07 GMT</pubDate>
            <atom:updated>2024-09-23T17:51:09.733Z</atom:updated>
            <content:encoded><![CDATA[<h3>JSON to JSON transformation with a template — engine comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H68LETz_60Xn_iUd" /><figcaption>Photo by <a href="https://unsplash.com/@raziii1375?utm_source=medium&amp;utm_medium=referral">Razieh Bakhtom</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When I think of using templates as a software engineer, I think of the following use cases:</p><ul><li>generating a payload in a certain format, be it a YAML, JSON, terraform config, SQL statement by filling in the gaps with environment variables or a context map</li><li>generating a customer email</li><li>generating a business report</li><li>generating a web page</li></ul><p>However, it’s also possible to use a template to <strong>transform a payload. </strong>It’s not a revolutionary idea, it’s rather a slight shift in the thought process — from “I can use templates to <strong>generate stuff” </strong>to<strong> </strong>“I can use templates to<strong> transform stuff”.</strong></p><p>There are dozens and dozens of template engines in a variety of languages. Most, however, are tailored for use as web page templates. This is a pro and a con though.</p><p>The positive side is — if a template is meant to be used to render a page then it should be incredibly fast, because let’s be honest, who’s waiting for a page to load more than 10ms nowadays.</p><p>The negative side, or the negative from my perspective, is that most use JS or Ruby, whereas I was interested in those I can use with JVM languages.</p><p>After a review, I ended up short-listing the following 4 engines I wanted to analyse:</p><ul><li><a href="https://github.com/HubSpot/jinjava">Jinja</a></li><li><a href="https://github.com/schibsted/jslt">JSLT</a></li><li><a href="https://freemarker.apache.org/">Apache FreeMaker</a></li><li><a href="https://velocity.apache.org/engine/1.7/user-guide.html#velocity-template-language-vtl-an-introduction">Apache Velocity</a></li></ul><p>The criteria for assessment:</p><ul><li>ease of use</li><li>provided functions/macros</li><li>extensibility</li><li>performance when processing small simple payloads</li><li>performance when processing small payloads using custom functions (do those affect the speed at all)</li><li>performance when processing big payloads</li></ul><p>So, let’s dive in!</p><h3>Jinja</h3><h4>Dependencies required</h4><pre>implementation(&quot;com.hubspot.jinjava:jinjava:2.7.2&quot;)</pre><h4>Creating the template</h4><pre>{<br>    &quot;fullName&quot;: &quot;{{ full_name }}&quot;,<br>    &quot;uid&quot;: &quot;{{ uid }}&quot;,<br>    &quot;contactDetails&quot;: {<br>        &quot;address&quot;: {<br>            &quot;street&quot;: &quot;{{ address.street }}&quot;,<br>            &quot;city&quot;: &quot;{{ address.city }}&quot;<br>        },<br>        &quot;emailAddress&quot;: &quot;{{ email }}&quot;,<br>        &quot;phoneNumber&quot;: &quot;{{ phone }}&quot;<br>    },<br>    &quot;paymentDetails&quot;: [<br>     {% for details in payment_details %}<br>        {<br>            &quot;IBAN&quot;: &quot;{{ details.iban }}&quot;,<br>            &quot;cardDetails&quot;: {<br>                &quot;number&quot;: &quot;{{ details.credit_card_number }}&quot;,<br>                &quot;CVV&quot;: &quot;{{ details.credit_card_cvv }}&quot;<br>            },<br>            &quot;currency&quot;: &quot;{{ details.currency }}&quot;<br>        }{% if not loop.last %},{% endif %}<br>     {% endfor %}<br>    ],<br>    &quot;lastUpdated&quot;: &quot;{{ last_updated }}&quot;,<br>    &quot;createdAt&quot;: &quot;{{ created_at }}&quot;<br>}</pre><h4>Initialization</h4><pre>private val jinjava = Jinjava()</pre><h4>Adding custom functions</h4><pre><br>// fun without any parameters<br>private val timeNowFunc =<br>        ELFunctionDefinition(<br>            &quot;&quot;,<br>            &quot;timeNow&quot;,<br>            CustomFunctions::class.java,<br>            &quot;timeNow&quot;<br>        )<br>// fun with parameters   <br>private val mapCurrencyFunc =<br>        ELFunctionDefinition(<br>            &quot;&quot;,<br>            &quot;mapCurrency&quot;,<br>            CustomFunctions::class.java,<br>            &quot;mapCurrency&quot;,<br>            String::class.java<br>        )<br><br>init {<br>    jinjava.globalContext.registerFunction(timeNowFunc)<br>    jinjava.globalContext.registerFunction(mapCurrencyFunc)<br>}</pre><h4>Applying the template</h4><pre>// simply:<br>jinjava.render(template, context)<br>// where &#39;template&#39; is the loaded template as a string and<br>// the context is the input JSON as a Map&lt;String, Any?&gt;</pre><h3>JSLT</h3><h4>Dependencies required</h4><pre>implementation(&quot;com.schibsted.spt.data:jslt:0.1.14&quot;)</pre><h4>Creating the template</h4><pre>let paymentDetails = [for (.payment_details)<br>  {<br>    &quot;IBAN&quot;: .iban,<br>    &quot;cardDetails&quot;: {<br>        &quot;number&quot;: .credit_card_number,<br>        &quot;CVV&quot;: .credit_card_cvv<br>    },<br>    &quot;currency&quot;: .currency<br>  }<br>]<br>{<br>    &quot;fullName&quot;: .full_name,<br>    &quot;uid&quot;: .uid,<br>    &quot;contactDetails&quot;: {<br>        &quot;address&quot;: {<br>            &quot;street&quot;: .address.street,<br>            &quot;city&quot;: .address.city<br>        },<br>        &quot;emailAddress&quot;: .email ,<br>        &quot;phoneNumber&quot;: .phone<br>    },<br>    &quot;paymentDetails&quot;: $paymentDetails,<br>    &quot;lastUpdated&quot;: .last_updated,<br>    &quot;createdAt&quot;: .created_at<br>}</pre><h4>Initialization</h4><pre>// no init required here</pre><h4>Adding custom functions</h4><pre>// fun without any parameters<br>class TimeNow : Function {<br>    override fun getName() = &quot;timeNow&quot;<br><br>    override fun getMaxArguments() = 0<br><br>    override fun getMinArguments() = 0<br><br>    override fun call(jsonNode: JsonNode?, jsonNodes: Array&lt;JsonNode?&gt;): JsonNode {<br>        return JsonNodeFactory.instance.textNode(CustomFunctions.timeNow())<br>    }<br>}<br><br>// fun with parameters<br>class MapCurrency : Function {<br>    override fun getName() = &quot;mapCurrency&quot;<br><br>    override fun getMaxArguments() = 1<br><br>    override fun getMinArguments() = 1<br><br>    override fun call(jsonNode: JsonNode?, jsonNodes: Array&lt;JsonNode&gt;): JsonNode {<br>        return JsonNodeFactory.instance.textNode(<br>            CustomFunctions.mapCurrency(jsonNodes[0].asText())<br>        )<br>    }<br>}<br><br>// since no init required, no need to register those custom functions as well<br>     </pre><h4>Applying the template</h4><pre>// simply:<br>val functions = listOf(<br>        TimeNow(),<br>        MapCurrency()<br>    )<br>Parser.compileString(template, functions.apply(input)<br>// where &#39;template&#39; is the loaded template as a string and<br>// the context is the input JSON as a JsonNode</pre><h3>Apache FreeMaker</h3><h4>Dependencies required</h4><pre>implementation(&quot;org.freemarker:freemarker:2.3.33&quot;)<br>implementation(&quot;org.freemarker:freemarker-gae:2.3.33&quot;)</pre><h4>Creating the template</h4><pre>{<br>    &quot;fullName&quot;: &quot;${full_name}&quot;,<br>    &quot;uid&quot;: &quot;${uid}&quot;,<br>    &quot;contactDetails&quot;: {<br>        &quot;address&quot;: {<br>            &quot;street&quot;: &quot;${address.street}&quot;,<br>            &quot;city&quot;: &quot;${address.city}&quot;<br>        },<br>        &quot;emailAddress&quot;: &quot;${email}&quot;,<br>        &quot;phoneNumber&quot;: &quot;${phone}&quot;<br>    },<br>    &quot;paymentDetails&quot;: [<br>    &lt;#list payment_details as details&gt;<br>        {<br>            &quot;IBAN&quot;: &quot;${details.iban}&quot;,<br>            &quot;cardDetails&quot;: {<br>                &quot;number&quot;: &quot;${details.credit_card_number}&quot;,<br>                &quot;CVV&quot;: &quot;${details.credit_card_cvv}&quot;<br>            },<br>            &quot;currency&quot;: &quot;${details.currency}&quot;<br>        }&lt;#if details_has_next&gt;,&lt;/#if&gt;<br>    &lt;/#list&gt;<br>    ],<br>    &quot;lastUpdated&quot;: &quot;${last_updated }&quot;,<br>    &quot;createdAt&quot;: &quot;${created_at }&quot;<br>}</pre><h4>Initialization</h4><pre>private val cfg = Configuration(Configuration.VERSION_2_3_31)<br><br>init {<br>    cfg.setClassForTemplateLoading(FreeMakerTransformer::class.java, &quot;/&quot;)<br>    cfg.defaultEncoding = &quot;UTF-8&quot;<br>    cfg.templateExceptionHandler = TemplateExceptionHandler.IGNORE_HANDLER<br>    cfg.logTemplateExceptions = true<br>    cfg.wrapUncheckedExceptions = true<br>    cfg.outputFormat = JSONOutputFormat.INSTANCE<br>    cfg.templateNameFormat = TemplateNameFormat.DEFAULT_2_4_0<br>    cfg.unsetLocale()<br>}</pre><h4>Adding custom functions</h4><pre>// fun without any parameters<br>class TimeNow2 : TemplateMethodModel {<br>    override fun exec(p0: List&lt;Any?&gt;?) =<br>        CustomFunctions.timeNow()<br>}<br><br>// fun with parameters<br>class MapCurrency2 : TemplateMethodModel {<br>    override fun exec(p0: List&lt;Any?&gt;?) =<br>        p0?.get(0)?.toString()?.let { CustomFunctions.mapCurrency(it) }<br>}<br><br>// register<br>cfg.setSharedVariable(&quot;timeNow&quot;, TimeNow2())<br>cfg.setSharedVariable(&quot;mapCurrency&quot;, MapCurrency2())</pre><h4>Applying the template</h4><pre>// simply:<br>val template = cfg.getTemplate(templateFileName)<br>template.numberFormat = &quot;c&quot;<br><br>val writer = StringWriter()<br>template.process(context, writer)<br>return writer.toString()<br>// where &#39;templateFileName&#39; is the path to the template file in the resources <br>// and he context can be a Map or a POJO</pre><h3>Apache Velocity</h3><h4>Dependencies required</h4><pre>implementation(&quot;org.apache.velocity:velocity:1.7&quot;)<br>implementation(&quot;org.apache.velocity:velocity-tools:2.0&quot;)</pre><h4>Creating the template</h4><pre>{<br>    &quot;fullName&quot;: &quot;${full_name}&quot;,<br>    &quot;uid&quot;: &quot;${uid}&quot;,<br>    &quot;contactDetails&quot;: {<br>        &quot;address&quot;: {<br>            &quot;street&quot;: &quot;${address.street}&quot;,<br>            &quot;city&quot;: &quot;${address.city}&quot;<br>        },<br>        &quot;emailAddress&quot;: &quot;${email}&quot;,<br>        &quot;phoneNumber&quot;: &quot;${phone}&quot;<br>    },<br>    &quot;paymentDetails&quot;: [<br>    #foreach($details in $payment_details)<br>        {<br>            &quot;IBAN&quot;: &quot;${details.iban}&quot;,<br>            &quot;cardDetails&quot;: {<br>                &quot;number&quot;: &quot;${details.credit_card_number}&quot;,<br>                &quot;CVV&quot;: &quot;${details.credit_card_cvv}&quot;<br>            },<br>            &quot;currency&quot;: &quot;${details.currency}&quot;<br>        }#if( $foreach.hasNext ), #end<br>    #end<br>    ],<br>    &quot;lastUpdated&quot;: &quot;${last_updated}&quot;,<br>    &quot;createdAt&quot;: &quot;${created_at}&quot;<br>}</pre><h4>Initialization</h4><pre>private val velocityEngine = VelocityEngine()<br> <br>init {<br>  velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, &quot;classpath&quot;)<br>  velocityEngine.setProperty(&quot;classpath.resource.loader.class&quot;, ClasspathResourceLoader::class.java.name)<br>  velocityEngine.init()<br>}</pre><h4>Adding custom functions</h4><pre>// no need to implement a provided intereface, <br>// just passing the Object with the funcs when applying the template<br> private val defaultContext = VelocityContext().apply {<br>        put(&quot;customFunctions&quot;, CustomFunctions::class.java)<br>}</pre><h4>Applying the template</h4><pre>// simply:<br>val t = velocityEngine.getTemplate(template)<br>val vContext = VelocityContext(context, defaultContext)<br><br>val writer = StringWriter()<br><br>t.merge(vContext, writer)<br><br>writer.toString()<br>// where &#39;template&#39; is the path to the template file in the resources <br>// and he context is a Map</pre><h3>Testing</h3><p>For input I generated a mock JSON with <a href="https://mockturtle.net/">https://mockturtle.net/</a></p><pre>{<br>  &quot;full_name&quot;: &quot;Edmund Monahan&quot;,<br>  &quot;address&quot;: {<br>    &quot;street&quot;: &quot;755 Edna Spur&quot;,<br>    &quot;city&quot;: &quot;Florida&quot;<br>  },<br>  &quot;payment_details&quot;: [<br>    {<br>      &quot;iban&quot;: &quot;TR6532729HQDSUUT8JG7ZWXF41&quot;,<br>      &quot;credit_card_number&quot;: &quot;3605846184452422&quot;,<br>      &quot;currency&quot;: &quot;Seychelles Rupee&quot;,<br>      &quot;credit_card_cvv&quot;: &quot;951&quot;<br>    }<br>    ...<br>  ],<br>  &quot;email&quot;: &quot;Edmund91@yahoo.com&quot;,<br>  &quot;phone&quot;: &quot;253-835-7495&quot;,<br>  &quot;uid&quot;: &quot;acf8b039-dc52-4e19-9acd-60c8cba5cc5e&quot;,<br>  &quot;last_updated&quot;: &quot;2023-10-18&quot;,<br>  &quot;created_at&quot;: &quot;2024-05-18&quot;<br>}</pre><p>Following the chosen criteria I ran 3 sents of tests.</p><h4>Simple Small Input</h4><pre>@Test<br>    fun jinjaSingleInput() {<br>        val template = readResource(&quot;templates/single-input.jinja&quot;)<br>        val context = mapper.readValue(singleInput, mapTypeRef)<br>        calcAvgTime { JinjaTransformer.applyTemplate(context, template) }<br>    }<br><br>    @Test<br>    fun jsltSingleInput() {<br>        val template = readResource(&quot;templates/single-input.jslt&quot;)<br>        val context = mapper.readValue(singleInput, nodeTypeRef)<br>        calcAvgTime { JsltTransformer.applyTemplate(context, template) }<br>    }<br><br>    @Test<br>    fun freeMakerSingleInput() {<br>        val context = mapper.readValue(singleInput, mapTypeRef)<br>        calcAvgTime FreeMakerTransformer.applyTemplate(context, &quot;templates/single-input.ftl&quot;) }<br>    }<br><br>    @Test<br>    fun velocitySingleInput() {<br>        val context = mapper.readValue(singleInput, mapTypeRef)<br>        calcAvgTime { VelocityTransformer.applyTemplate(context, &quot;templates/single-input.vm&quot; }<br>    }</pre><h4>Small Input with custom Functions</h4><p>The code for that is the same. The only difference here is that I created a copy of the templates with calls to the added custom functions.</p><h4>Big Input</h4><p>In order to test the limitations and control the size of the payload, I was generating that dynamically like so:</p><pre>@Test<br>fun jinjaMultiInput() {<br>    val template = readResource(&quot;templates/multi-input.jinja&quot;)<br>    val singleResult = mapper.readValue(singleInput, mapTypeRef)<br>    val context = mutableMapOf&lt;String, Any?&gt;()<br><br>    // 100<br>    context[&quot;results&quot;] = (0..100).map { singleResult }<br>    calcAvgTime{ JinjaTransformer.applyTemplate(context, template) }<br>    // 1000<br>    context[&quot;results&quot;] = (0..900).map { singleResult }<br>    calcAvgTime{ JinjaTransformer.applyTemplate(context, template) }<br>    // 10_000<br>    context[&quot;results&quot;] = (0..9000).map { singleResult }<br>    calcAvgTime{ JinjaTransformer.applyTemplate(context, template) }<br>    // 100_000<br>    context[&quot;results&quot;] = (0..60_000).map { singleResult }<br>    calcAvgTime{ JinjaTransformer.applyTemplate(context, template) }<br>}</pre><p>The code for the other Transformers is almost identical, you get the jyst.</p><h3>Evaluation based on selected criteria</h3><h4>Ease of use</h4><p>All have similar syntax, so I’d say there is no obvious winner in that regard</p><h4>Built-in functions</h4><p><strong><em>JSLT</em></strong> and <strong><em>FreeMaker</em></strong> come in with some commonly used built-in functions (like uuid, parsing datetime etc). So, those are definitely leading here.</p><h4>Extensibility</h4><p>All engines allow defining custom functions.</p><p>Some, like FreeMaker, Velocity and JSLT allow that to be done inside the template as well as in the language used to parse the template.</p><p>JSLT and FreeMaker are a little more verbose — you need to override the interface provided and register those functions upon initialization of the engine or pass them when parsing the template.</p><p>Jinja is no better, it needs you to create a function definition instance and register that.</p><p><strong><em>Velocity</em></strong> is the winner for me here, because it just requires passing in the class where the functions are defined in the context.</p><h4>Performance when processing small payloads</h4><p>To avoid evaluating the jvm and give the engine time to warm up I am using the average processing times out of 100 repetitions.</p><p>Times were as follows: Jinja — 1.8ms, JSLT — 0.46ms, FreeMaker — 0.11ms, Velocity — 0.18.ms.</p><p><strong><em>FreeMaker</em></strong> is clearly crushing it on average, although Velocity was quicker in the first iterations and JSLT in the latest ones.</p><h4>Performance when processing small payloads with custom functions</h4><p>Times were as follows: Jinja — 1.88ms, JSLT — 0.68ms, FreeMaker — 0.13ms, Velocity — 0.32ms</p><p>Again, <strong><em>FreeMaker</em></strong> is in the lead, although I observed the same difference in the first and later rounds.</p><p>Velocity appeared to have the biggest impact from the added custom function calls.</p><h4>Performance when processing big payloads</h4><p>Size | Jinja | JSLT | FreeMaker | Velocity<br>~80 KB | 5.12 | 0.65 | 0.66 | 1.07<br>~707 KB | 13.93 | 1.53 | 2.49 | 6.78<br>~7.2MB | 130.99 | 16.72 | 24.92 | 64.52<br>~47.8MB | 876.41 | 199.14 | 165.25 | 425.25</p><p>Based on these numbers, JSLT and FreeMaker are neck and neck.</p><p>Overall, I’d say **<strong>FreeMaker**</strong> is the clear winner in terms of performance and with that can compensate for any inconvenience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5d394a9ee3b" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/json-to-json-transformation-with-a-template-engine-comparison-d5d394a9ee3b">JSON to JSON transformation with a template — engine comparison</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Graph Databases — what those are and where they might be useful]]></title>
            <link>https://medium.com/@ivs.yordanova/graph-databases-what-those-are-and-where-they-migth-be-useful-25b298fe448a?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/25b298fe448a</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[graph-database]]></category>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[neptune]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 09:03:57 GMT</pubDate>
            <atom:updated>2024-02-16T08:55:29.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>Graph Databases — what those are and where they might be useful</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6_AcIyXTYcvSawAN" /><figcaption>Photo by <a href="https://unsplash.com/@alinnnaaaa?utm_source=medium&amp;utm_medium=referral">Alina Grubnyak</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve worked in a few companies as a Software engineer and all of them did value learning and development. However, I do appreciate how fortunate I’ve been to start my first Data Engineering role in a place that not only values but also actually facilitates learning and experimenting with new technologies, methodologies and languages by constantly trying to stay ahead of the curve and innovating.</p><p>Simply Business (SB) is a digital insurer for small businesses in the US and UK, with over 1 Million customers. The business is always looking for ways to identify and solve customer problems, to create a customer journey that stands out from our competitors.</p><p>Like many companies, SB has customer data coming from a variety of first and third-party sources, exported to and from third-party tools and frameworks. We’re also actively looking to enrich what we already have by bringing in publicly available data.</p><p>Due to varying sources, there can be genuine errors, such as typos, incorrect entries, etc. These are standard challenges for any company to deal with that can get caught in data checks.</p><p>Creating a unified customer view can be challenging with traditional tools and methods, so we started exploring a better way to achieve this. One approach we’re looking at is using graph databases, great for entity resolution (ER), determining which pieces of data relate to the same real-world entity.</p><p>A customer graph makes it possible to see the full journey of an individual, and how it represents the overall organisation landscape, in a way which can be used to improve business insights.</p><p>Having a graph of all aspects known about the customer would allow us to execute up-to-date rich queries on customers and analyse or discover trends we were not equipped to notice previously. It could provide insights, such as deep dives on particular segments of customers and aggregations of behaviour, based on marketing events, clicks, interactions, and purchases.</p><p>As we reach a more stable state of the graph, we can apply business rules on top of it to reconcile value differences, which cannot be caught by simple comparison. We can also create machine learning models we haven’t been able to before by using the features developed from customer data.</p><h3>What are Graph Databases?</h3><p>When most people hear the word “database”, they think of a table with several rows and columns, a <strong>relational database</strong>. The data is modelled as a collection of tables that could be joined together via a primary or a foreign key. These keys are unique identifiers that implicitly demonstrate different relationships between the tables. Analysts need to know the ins and outs of each piece of data coming into the databases and then create models on top of the raw tables using SQL queries to combine the different data points.</p><p>Simply Business stores raw analytics data in Snowflake, a column-oriented, cloud-based database for optimised reading and analytics. That “raw” data is transformed and aggregated to generate various reports for the business.</p><p><strong>Graph databases</strong> focus on the relationships between individual data points. Data is modelled and thought of as nodes and edges. A node is a single data entity, and an edge is the connection between two nodes.</p><p>Each <strong>node</strong> has an <em>identifier</em>, a label<em>,</em> and several<em> properties. </em>These can loosely be thought of as equivalent to the primary key, table and the rest of the columns in that table. Each <strong>edge</strong> has an <em>identifier </em>and a <em>type, </em>which describes a parent-child relationship, action, ownership, and any other relevant relationship. There is no limitation on the number of relationships a node can have, and each has a type, however, graph databases are considered the optimal solution for sparse graphs, where the No relationships &lt; No nodes2 .</p><h3>What are the benefits of using a Graph Database?</h3><p>Generally, graph databases are used for:</p><ul><li>Fraud detection</li><li>360° customer views</li><li>Recommendation engines</li><li>Network/Operations mapping</li><li>AI knowledge graphs</li></ul><p>To demonstrate why we’re interested in graph databases, it’s helpful to have a simplified example to work with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Nho4x32mvuOcOBB" /></figure><p>From this example, it’s clear to see how relational databases have some limitations compared to graph databases.</p><h4><strong>Multi-hop queries</strong></h4><p>As demonstrated above, we don’t receive all information for a person or business in a single, well-structured and easy-to-manage block of data. We have over 500 individual data points from our own Simply Business sources alone, combined with things happening on the website, in backend applications, completed forms, etc. To make sense of these and present the business with a unified view of what’s happening in the organisation, analysts need to know of all these and be able to join them based on identifiers.</p><p>The schema above is simplified in that regard. In reality, we don’t always have the same ID across all data points, and joining two of them might require jumping through a few hoops using a variety of identifiers. With SQL and relational databases this could very easily and quickly get incredibly confusing and complex, opening the door for errors. This is already a challenge to work with before adding the additional difficulty of integrating entities from external sources, which can have entirely different sets of identifiers in different formats and structures.</p><p>Graph databases store their relationships, so the “joining” doesn’t need to be created with a custom logic on top of the static data in runtime. Instead, it is just traversing the paths between the nodes, which can be expressed more easily, making it more natural to understand using languages like Gremlin or Opencypher.</p><h4><strong>Performance</strong></h4><p>Relational databases use index lookups and scan tables to identify relationships between entities. This is time-consuming as the system has to scan larger indices over more data. Additionally, since that is happening at query or run time, it requires a lot of compute power therefore costing more.</p><p>Graph databases store relationships as references or pointers between nodes, a database can follow a memory pointer and quickly navigate between entities. Graph databases don’t need indexes or mapping tables which allow them to achieve constant-time traversal, meaning in the same amount of time, no matter the data size.</p><h4><strong>Flexibility</strong></h4><p>Applying changes to a relational database model usually involves slow and costly schema changes. Raw tables and views need to be recreated, data types casted, and every view or table created on top of those raw source tables needs updating to reflect these changes.</p><p>In a graph, the data model can be modified continually. Complex interdependent relationships between data entities can be added, edited, and removed easily. Individual properties in a node can be added, removed or changed without affecting the rest of the data in the same node and other nodes.</p><h4><strong>Entity Matching</strong></h4><p>In relational databases, ER is a cumbersome process, due to the reasons above, that gets exponentially more complex, harder to maintain, and more time-consuming without providing the desired effect.</p><p>In graph databases, each node and relationship has a unique identifier, so new properties are automatically added, and new relationships are attached to the existing nodes. This functionality is out of the box, not requiring any computing, as long as the correct identifiers are attached.</p><p>Additionally, with graph databases, it’s easier to make sense of the rest of the nodes, which do not match perfectly, because there are a variety of <strong>graph algorithms</strong> available for discovering similarities or anomalies. These algorithms are well-tested and relatively easy to utilise by using any existing libraries and shared knowledge online.</p><p>The Neo4j Graph Data Science Library provides algorithms for similarity and community detection, which are used to identify links that are not easy to see with manually constructed queries. The <em>Node Similarity</em> algorithm can be used to generate weighted connections between nodes, and depending on business requirements a threshold can be chosen, above which entities are treated as equal. The process is straightforward, although compute-intensive. Another algorithm, <em>Weakly Connected Components</em>, can be used to detect subgraphs that are unreachable from other nodes of the graph. In addition to the static business rules and algorithms, ML models can help spot and predict links.</p><p>With a graph database, we are looking to unlock a variety of opportunities by allowing us to dynamically remove duplicates and reconcile different entities. Having cleaner, more consistent and less ambiguous data will allow us to respond faster to customer actions and even save money with better-targeted marketing campaigns, earlier detection and resolution of issues.</p><p>Watch out for updates on any insights and pitfalls we discover along the way:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25b298fe448a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debezium and Postgres — lessons learned from an odd case]]></title>
            <link>https://medium.com/@ivs.yordanova/debezium-and-postgres-lessons-learned-from-an-odd-case-b468fad3fca9?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/b468fad3fca9</guid>
            <category><![CDATA[debezium]]></category>
            <category><![CDATA[dba]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sun, 21 Jan 2024 16:29:04 GMT</pubDate>
            <atom:updated>2024-01-21T16:29:04.200Z</atom:updated>
            <content:encoded><![CDATA[<h3>Debezium and Postgres — lessons learned from an odd case</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AoAiQRNlyi6YMbnS" /><figcaption>Photo by <a href="https://unsplash.com/@danielmingookkim?utm_source=medium&amp;utm_medium=referral">Daniel Mingook Kim</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It would be a wonderful world if everything you ever work on is something you had the time to explore, learn about, experiment with, test, set up and deploy. However, reality is, you rarely have a couple of those covered, especially the “have the time to” part.</p><p>Sometimes, you <strong><em>get to</em></strong> learn at an intensified speed under the pressure of an ongoing issue. Those are the moments where any new piece of information gets engraved into your brain forever. So, I thought I might share a couple of interesting new things.</p><p>First, let’s take a step back and go over couple of bits as intro:</p><h3>What is Debezium?</h3><p><a href="https://debezium.io/">Debezium</a> is an open source tool for <strong>C</strong>hange <strong>D</strong>ata <strong>C</strong>apture. It’s meant to be as easy to use as simply configuring it to access your DB and it will automatically start “listening” for any <em>inserts</em>, <em>updates</em>, and <em>deletes</em> applied to the selected/whitelisted tables at row level and streaming those changes to Kafka. These events are emitted in the same order they were applied so they can then be used by some apps to react in near real time to changes made by other apps directly in the DB, to sync other data sources and more.</p><p>The goal of this is to separate the responsibilities of each app, instead of having one monster service doing it all — updating the DB updates, publishing notifications and event and everything else that the source data can be used for.</p><p>There are<a href="https://debezium.io/documentation/reference/2.5/connectors/index.html"> multiple ready-to-use connectors</a> provided for a variety of different DBs.</p><h3>How does Debezium work?</h3><p>In short, Debezium works by reading any new changes from the WAL files (<a href="https://www.postgresql.org/docs/current/wal-intro.html"><em>write ahead logging</em></a>) in Postgres (or any other DB supporting tha mechanism, which is most of them) and creating a “replication slot”. The latter is essentially an entry in a table with an id/name for the replication slot, columns for flush and restart LSN (<a href="https://www.postgresql.org/docs/current/wal-internals.html"><em>Log Sequence Number</em></a>) and few more details. The LSN is a string that tells the exact location of a record in a WALL file — it’s a combination of the WAL file name + the offset from the start in that file where a record “lives”.</p><p>The LSNs get updated by Debezium every time it makes some progress:</p><ul><li><strong>Flush LSN</strong> indicates the offset that Debezium has reached — it has read and successfully written to Kafka everything up to that offset. This gets updated only if there is some activity in the tables. Consequently, if there are no new records inserted, updated, deleted in the db, Debezium won’t attempt to read them and won’t progress. Change here can be easily triggered by a dummy update (changing a col value to the same one). Even though there is no real change, the execution of an UPDATE statement is noted in the WAL file and it would be picked up, then on successful write to Kafka, Debezium would also update the flush LSN.</li><li><strong>Restart LSN</strong> indicates the offset Debezium will start reading from when it restarts. This is not updated while there are any running transactions.</li></ul><p>Now, knowing all that, let’s see where some potential issues might arise:</p><h4>1. The never updated restart LSN</h4><p>If the application writing to the DB has an issue and is unable to complete a transaction, or by some weird reason there is one left open for a long time, then the restart LSN never updates.</p><p>In the meantime if Debezium restarts multiple times, it will keep requesting all the data from that restart LSN until the current moment. This can be an increasingly large amount of data, which would lead to spikes in the <em>ReadIOPs </em>to a point where the DB becomes practically unusable by other connections or apps. At the same time, Debezium will look like it’s making no progress at all and lagging — the <em>OldestReplicationSlotLag </em>metric will keep increasing,</p><h4>2. The forgotten replication slots</h4><p>Always, always ..always clean up after yourself.</p><p>WAL files are shared, same ones for the whole db. They would be kept around as long as there is a replication slot, whether active or not, that refers to one of them through a LSN.</p><p>This means that if you have a replication slot you no longer use, but forget to drop it from the DB, it will keep referencing the last LSN it got to forever and this will slowly but surely degrade the performance of your DB. Depending on the size of data and frequency of changes, you’ll end up with TB and TB worth of WAL files lying around.</p><p>The danger of those is not simply the amount of disk space they’ll take. The worst part is that these would also prevent the auto-vacuum to run and clean up all the dead tuples in your tables.<a href="https://www.postgresql.org/docs/current/sql-vacuum.html"> <strong>Vacuuming</strong></a> is a process of removing dead tuples and reclaiming storage — it’s kind of like the garbage collection process in JVM where an object you don’t reference and is out of scope doesn’t immediately disappear but needs to be garbage-collected. Similarly, deleted records in a table don’t actually get removed until a vacuum is run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b468fad3fca9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pyspark — Save vs. SaveToTable]]></title>
            <link>https://medium.com/better-programming/pyspark-save-vs-savetotable-50cfac32a5e2?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/50cfac32a5e2</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 18:22:36 GMT</pubDate>
            <atom:updated>2022-07-04T05:17:59.041Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pyspark — save vs. saveToTable</h3><h4>A cautionary tale of side effects that will have you scratching your head for a minute</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lcKABVHgbuBhSLPl" /><figcaption>Photo by <a href="https://unsplash.com/@cedericvandenberghe?utm_source=medium&amp;utm_medium=referral">Cederic Vandenberghe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The most prolific programming meme is probably the one showing an exhausted, tortured developer with head in hands and some text indicating an infinite amount of time has passed debugging only to figure out it’s a ; missing somewhere.</p><p>Now, with modern IDEs that’s not as relevant but the sentiment is there, there are so many cases where you’d end up spending way more time than expected debugging something, with sometimes significant effects, that ends up being caused by a typo that accidentally matches a valid keyword, a wrong indent, forgotten debugging statement or any tiny annoying detail that should not have caused you all that pain.</p><p>I am going to share one similar example where unexpected side effects of one function left me confused for a bit. That’s why side effects are wrong, do NOT do that in your code, just don’t.</p><p>Let me set the scene — I was working on a new rather POC bit of code and experimenting on a Jypither notebook in Databricks with pyspark. In the initial phase, I was pulling, processing data, and persisting it with saveAsTable since the cluster I was using is only serving as a test/dev/experimentation environment so it was getting shut down after use.</p><p>In most scenarios, to have your data be useful for other services or people, to be analyzed or queries, it will need to be put into external storage that makes sense, in this case — snowflake. Thankfully, writing data to snowflake from databricks is as easy as:</p><pre>user = dbutils.secrets.get(&quot;snowflake&quot;, &quot;&lt;user&gt;&quot;)<br>password = dbutils.secrets.get(&quot;snowflake&quot;, &quot;&lt;password&gt;&quot;)</pre><pre>df.write \<br>      .format(&quot;snowflake&quot;) \<br>      .option(&quot;sfUrl&quot;, &quot;&lt;url&gt;&quot;) \<br>      .option(&quot;sfUser&quot;, user) \<br>      .option(&quot;sfPassword&quot;, password) \<br>      .option(&quot;sfWarehouse&quot;, &quot;&lt;warehouse&gt;&quot;) \<br>      .option(&quot;sfDatabase&quot;, &quot;&lt;db&gt;&quot;) \<br>      .option(&quot;sfSchema&quot;, &quot;&lt;schema&gt;&quot;) \<br>      .option(&quot;sfRole&quot;, &lt;role&gt;) \<br>      .option(&quot;dbtable&quot;, &quot;MY_TABLE&quot;) \<br>      .mode(&quot;&lt;mode&gt;&quot;) \<br>      .option(&quot;inferSchema&quot;,&quot;true&quot;) \<br>      .<strong>save</strong>(result_table)</pre><p>Now, note that save there, well, I accidentally did not change it from the previous saveAsTable. Instead, I just added the relevant options, ran it, waited a bit and there it was — the command succeeded and the table, as expected, was really created in Snowflake. There was no indication that this is not the way I was supposed to save my data, not at all.</p><p>So, I finished the task and moved on for a few days to the next thing. Then, as you might expect from something in such an early stage of development, changes needed to be made — columns renamed, dropped, added. I did all that directly in Snowflake, since at the time I was oblivious to the fact this is not the only instance of my table (insert dramatic music here ). Additionally, I also had to process another batch of data (with the new schema) and append it to the already existing table.</p><p>When I ran the same set of commands again, the last step of saving to the table failed with The number of columns doesn’t match. The exact error message is way more verbose and will list all columns in the data you are trying to save and the table you are trying to save in. That’s the fun part — it was listing the old set of columns, the ones before I made the edits in Snowflake, which confused me. OK, so maybe there is some sort of local cache — tried the ultimate solutions — turning off and on again. No luck.</p><p>I spent more time than I would like to admit until I spotted that I am using saveAsTable and in the Databricks Data tab I had the same table with the old schema. This made me sooo mad. Why would that function silently write to both? If it writes to both, then why doesn’t it pick up the fact both are out of sync?</p><p>What’s more — there is nothing about this mentioned<a href="https://spark.apache.org/docs/3.1.1/api/python/reference/api/pyspark.sql.DataFrameWriter.saveAsTable.html"> in the official documentation</a>. It only talks about saving to a specified table. I don’t want to sound like I am putting all of the blame on pyspark, no I take full responsibility for my part. However, it’s against all best practices to silently, behind the scenes make changes, especially ones that only work once. If it writes to both, advertise it as such, check both are in sync and give reasonable error messages. If not, just throw an error.</p><p>Anyway, I hope that might be useful for someone else.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50cfac32a5e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/pyspark-save-vs-savetotable-50cfac32a5e2">Pyspark — Save vs. SaveToTable</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Importing Resources Into Cloudformation Stack]]></title>
            <link>https://medium.com/better-programming/importing-resources-into-cloudformation-stack-6db614f1708b?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/6db614f1708b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 08:25:15 GMT</pubDate>
            <atom:updated>2022-06-27T10:15:52.455Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fixing “resource already exists” error. Or stacks stuck in “UPDATE_ROLLBACK_FAILED” state</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fSj2ziaAsQyJdxwT" /><figcaption>Photo by <a href="https://unsplash.com/@mrpeker?utm_source=medium&amp;utm_medium=referral">Mehmet Ali Peker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Infrastructure as a code is pretty much a standard across the board now, it’s not a novelty. In some companies, developers won’t even have access to the convenient UI of their cloud provider (or at least have very limited access). Instead, all the infrastructure resources are provisioned and defined as code in order to keep track of all the changes.</p><p>The benefits of IaC are apparent and I won’t go into depth, that’s beside the point of this story. However, I’ll mention the main one which relates directly to what I want to discuss — using frameworks like AWS Cloudformation or Terraform is meant to run all sorts of validations and shout out when things are inconsistent, it’s meant to save you from making irreversible big mistakes giving you the confidence to make changes.</p><p>Cloudformation is AWS’s service that would take the case of creating all the resources and define all the interdependencies based on a JSON or YAML template you create. Each template defines a <strong>stack</strong> of resources and each time the service runs it applies the whole template — it creates a changeset and recreates or deletes anything that doesn’t match the current state.</p><p>This bit can be somewhat problematic in 2 situations:</p><ol><li>You have a resource that you have created either through another service, manually in the UI or the terminal. Now, you need to “attach” this resource to an existing stack. If you just add the bucket to your template and run an update you’ll get an error saying “can’t create bucket X, it already exists”</li><li>You accidentally remove or rename a resource from your stack. This will result in the resource being “detached” from the stack. If it had the right retention policy, then the resource is just detached and not removed, but otherwise, you might delete vital data so make sure this is set right (deleted resources are also not the end of the world and there is a certain time in which you can still restore it but you might need all the help you can get from DevOps and AWS support). <br>An even worst-case scenario is to try and stop the run that does the update with the rename/removal. Cloudformation doesn’t handle that well and it will get stuck in UPDATE_ROLLBACK_FAILED state.</li></ol><p>Neither of those would happen on a daily basis but it’s not impossible and when something like this does happen, it might require very quick action and AWS provides a way for you to do that. Thankfully, a lot of resources can be imported, the full list of supported ones can be found<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html"> here</a>.</p><p>So, I am gonna describe the steps to fix your stack stuck in a weird state first, since that one is a bit more complicated:</p><h4>Restoring your Cloudformation stack</h4><p>Let’s assume the resource that was removed/renamed is a S3 bucket.</p><ol><li>Remove the renamed/accidentally removed bucket and all other resources referring to it from the template</li><li>Run a new update of the stack without those — this will remove any policies for example but if the retention is defined right it will NOT delete the bucket, just leave it in a sort of orphaned state, not belonging to a stack</li><li>Import the bucket with “DeletionPolicy”: “Retain” — you’ll need to provide an identifier property, defining the type of resource i.e AWS::S3::Bucket and identifier value, defining the name of the bucket. <br>!!! Make sure this is the right name of your existing bucket and it is not currently attached to another stack.<br>This only attaches the resource and doesn’t “apply” it. For example, if you have a BucketPolicy defined for that bucket and you have imported it, then you need to do step 3 before you see it added to the bucket.</li><li>Once the import is complete, add the bucket back into your template and run another update (you don’t need the deletion policy anymore here).</li></ol><h4>Importing existing resource</h4><p>The solution for this is just a subset of the previous one — steps 3 and 4 only</p><p>A detailed description of how to do the import can be found in AWS’ documentation<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html"> here</a>, so I am not going to repeat it.</p><p>hope that’s useful for someone out there.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6db614f1708b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/importing-resources-into-cloudformation-stack-6db614f1708b">Importing Resources Into Cloudformation Stack</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Geo Data Visualization With Kepler.gl]]></title>
            <link>https://medium.com/better-programming/geo-data-visualization-with-kepler-gl-fbc15debbca4?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbc15debbca4</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 22:27:44 GMT</pubDate>
            <atom:updated>2022-06-12T03:01:13.241Z</atom:updated>
            <content:encoded><![CDATA[<h4>Get a Python web service up and running in minutes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DqVc88HVcyh-zxpo" /><figcaption>Photo by <a href="https://unsplash.com/@kikisad?utm_source=medium&amp;utm_medium=referral">Killian Cartignies</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you have ever worked with any sort of geo data, you know it’s not super useful to just stare at it in a CSV, table or JSON format. You need to put it on a map in order to review it and spot any patterns. This might not be the end all be all way to gather insights, you’ll still need to do a proper analysis or/and run your ML models on it but it’s an absolute must.</p><h3><strong>What is Kepler.gl?</strong></h3><p><a href="https://kepler.gl/">Kepler.gl</a> is Uber’s open source project (GitHub <a href="https://github.com/keplergl/kepler.gl">link here</a>) for creating high-performing and data-agnostic web applications. It is built on top of <a href="https://www.mapbox.com/">Mapbox</a> and can handle large data sets, provides a lot of flexibility in terms of configuring what and how you want to visualize.</p><p>It uses layers as basic building blocks to allow you to create interactive maps — you can add, remove, show and hide layers, and change the way they look. This is a super basic example using a public flight data set from <a href="https://data.world/">data.world</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_e1dxvDdVdLPPPz4wnt4MQ.png" /></figure><p>As you can see you can layer out grids, points, arches/lines, polygons and even do a 3D map. There are ways for you to do very granular filtering (to the extent your dataset allows):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*Jjyno4N-OyKXJe3E91sbJg.png" /></figure><p>The dataset I am showing here only has 37,042 rows but I have tried it out with millions and it handles it pretty well. The geo calculations are GPU-accelerated for better performance.</p><p><a href="https://eng.uber.com/keplergl/">Here</a> is also a great post in Uber’s engineering blog with lots of examples of how data can be represented and more details on Kepler itself.</p><h3>Ways to use Kepler.gl?</h3><ul><li>upload a dataset on their <a href="https://kepler.gl/demo"><strong>demo page</strong></a> — if you want to check out what this is or if you need a one-off quick way of visualizing a moderate amount of non-sensitive data, this is the way to go.</li><li>as a <a href="https://docs.kepler.gl/docs/api-reference/get-started"><strong>react component</strong> </a>— if you want to embed this functionality in your existing project, this will give you a lot of control (over state, data flow, look, etc). Just do:</li></ul><pre>npm install kepler.gl</pre><ul><li>as a <a href="https://docs.kepler.gl/docs/keplergl-jupyter"><strong>python module</strong></a> — if you are a non-front-end expert and you need to get things done quickly and without too many fancy UI components besides the maps, this is the one for you. To start off, run:</li></ul><pre>pip install keplergl</pre><p>This last one is what I am gonna quickly go over to demonstrate how impressively quickly you can get an impressive MVP app up and running and present your data to impatient stakeholders or clients.</p><h3>Creating a web app with Kepler’s Python module</h3><p>I’m gonna make some quick assumptions — that you know a bit about python, pandas, and fast API (don’t need to be an expert to follow).</p><h4>1) let’s import what we need:</h4><pre>import uvicorn<br>import pandas as pd<br>from keplergl import KeplerGl <br>from fastapi import FastAPI<br>from fastapi.responses import HTMLResponse</pre><h4>2) load your data:</h4><pre># load a csv file<br>df = pd.read_csv(&#39;my_data.csv&#39;)<br># or a json file<br>df = pd.read_json(&#39;my_data.json&#39;)</pre><p>Now, this can and will probably be more than one file so just need to do that in a loop and combine the dataframes resulting from each file like this:</p><pre>all_data = pf.concat([all_data, df])</pre><h4>3) initialize Kepler.gl map:</h4><pre>kepler = KeplerGl(config=my_map_config)</pre><p>The config here is what you’ll probably need to play around a bit while you get it right for whatever your use case is.</p><p>To do that, at least for the purely representational side of it, the best way is to use a notebook to quickly load up your data and customize as needed, then export the config and apply it to your project. You can also either manually or programmatically adjust the parameters that matter from a more functional perspective.</p><p>An example config will be something like this:</p><pre>config = {<br>  &quot;version&quot;: &quot;v1&quot;,<br>  &quot;config&quot;: {<br>     &quot;visState&quot;: {<br>        &quot;filters&quot;: [<br>            {<br>              &quot;<strong>dataId</strong>&quot;: [&quot;my_data&quot;],<br>              &quot;id&quot;: &quot;11111&quot;,<br>              &quot;<strong>name</strong>&quot;: [&quot;some_col_name&quot;],<br>              &quot;type&quot;: &quot;multiSelect&quot;,<br>              &quot;value&quot;: [],<br>              &quot;enlarged&quot;: False,<br>              &quot;plotType&quot;: &quot;histogram&quot;,<br>              &quot;animationWindow&quot;: &quot;free&quot;,<br>              &quot;yAxis&quot;: None,<br>              &quot;speed&quot;: 1,<br>            }<br>        ],<br>        &quot;layers&quot;: [<br>            {<br>              &quot;id&quot;: &quot;22222&quot;,<br>              &quot;type&quot;: &quot;point&quot;,<br>              &quot;config&quot;: {<br>                  &quot;<strong>dataId</strong>&quot;: &quot;my_data&quot;,<br>                  &quot;label&quot;: &quot;my_data&quot;,<br>                  &quot;color&quot;: [30, 150, 190],<br>                  &quot;highlightColor&quot;: [252, 242, 26, 255],<br>                  &quot;isVisible&quot;: True,<br>                  &quot;visConfig&quot;: {<br>                      &quot;radius&quot;: 5,<br>                      &quot;fixedRadius&quot;: False,<br>                      &quot;opacity&quot;: 0.8,<br>                      &quot;outline&quot;: False,<br>                      &quot;thickness&quot;: 2,<br>                      &quot;strokeColor&quot;: None,<br>                       ...<br>                   },<br>                   &quot;hidden&quot;: False<br>              }<br>           }  <br>         ],<br>         &quot;interactionConfig&quot;: {<br>             &quot;tooltip&quot;: {<br>                 &quot;fieldsToShow&quot;: {<br>                     &quot;my_data&quot;: [<br>                         {&quot;name&quot;: &quot;col_1&quot;, &quot;format&quot;: None},<br>                         {&quot;name&quot;: &quot;col_2&quot;, &quot;format&quot;: None}  <br>                    ]<br>                 },<br>                 &quot;compareMode&quot;: False,<br>                 &quot;compareType&quot;: &quot;absolute&quot;,<br>                 &quot;enabled&quot;: True,<br>             },<br>             &quot;brush&quot;: {&quot;size&quot;: 0.5, &quot;enabled&quot;: False},<br>             &quot;geocoder&quot;: {&quot;enabled&quot;: False},<br>             &quot;coordinate&quot;: {&quot;enabled&quot;: False},<br>         },<br>         &quot;layerBlending&quot;: &quot;normal&quot;,<br>         &quot;splitMaps&quot;: [],<br>         &quot;animationConfig&quot;: {&quot;currentTime&quot;: None, &quot;speed&quot;: 1},<br>     },<br>     &quot;mapState&quot;: {<br>         &quot;bearing&quot;: 0,<br>         &quot;dragRotate&quot;: False,<br>         &quot;latitude&quot;: 40.710394,<br>         &quot;longitude&quot;: -74.000288,<br>         &quot;pitch&quot;: 0,<br>         &quot;zoom&quot;: 12.41,<br>         &quot;isSplit&quot;: False,<br>     },<br>     &quot;mapStyle&quot;: {<br>         &quot;styleType&quot;: &quot;dark&quot;,<br>         &quot;topLayerGroups&quot;: {},<br>         &quot;visibleLayerGroups&quot;: {<br>             &quot;label&quot;: True,<br>             &quot;road&quot;: True,<br>             &quot;border&quot;: False,<br>             &quot;building&quot;: True,<br>             &quot;water&quot;: True,<br>             &quot;land&quot;: True,<br>             &quot;3d building&quot;: False,<br>         },<br>         &quot;threeDBuildingColor&quot;: [<br>             9.665468314072013,<br>             17.18305478057247,<br>             31.1442867897876,<br>         ],<br>         &quot;mapStyles&quot;: {},<br>      },<br>  },<br>}</pre><p>Basically, there are 3 main sections — visState, mapState and mapStyle.</p><p><strong>MapState</strong> is used to define where on the world map you’ll start off every time you reload the page, the starting/default location.</p><p><strong>MapStyles</strong> set the general theme of the KeplerGl application. It has few preset options available like dark, muted night, light, muted light, and satellite.</p><p><strong>VizState</strong> is the more interesting one. It defines the <strong><em>layers</em></strong> (whether it’s point, hexagon, line etc ) and what dataset each layer to use — note that I put the dataId in bold, that is how you bind your data with the config, will show an example in the next section. You can also define <strong><em>filters</em></strong> that you can apply to one or more sets and base on one or more fields in that dataset. Additionally, here’s where you can define what you want to show in your tooltip (or other interactive option) and how.</p><h4>4) pass your data to Kepler</h4><pre># the name here should match the dataId in the config<br>kepler.add_data(data=all_data, name=&quot;my_data&quot;)</pre><h4>5) turn the map into HTML</h4><pre>kepler_html = kepler._repr_html_()</pre><h4>6) start up your app and return the generated HTML</h4><pre>app = FastAPI()</pre><pre>@app.get(&quot;/&quot;)<br>async def index():<br>   return HTMLResponse(content=kepler_html, status_code=200)</pre><pre>if __name__ == &quot;__main__&quot;:<br>   uvicorn.run(&quot;web_app:app&quot;, host=&quot;X&quot;, port=&quot;X&quot;)</pre><h4>7) have fun with it</h4><p>.. and thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbc15debbca4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/geo-data-visualization-with-kepler-gl-fbc15debbca4">Python Geo Data Visualization With Kepler.gl</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comparison of User Analytics and Data Tracking Tools]]></title>
            <link>https://medium.com/better-programming/user-tracking-and-analytics-tools-comparison-f1ab713e41e5?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1ab713e41e5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-collection]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Thu, 02 Jun 2022 10:15:18 GMT</pubDate>
            <atom:updated>2022-06-02T11:49:10.946Z</atom:updated>
            <content:encoded><![CDATA[<h4>Snowplow, Google Analytics, Segment, Amplitude, Rudderstack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JFbG6v00O74CR5QF" /><figcaption>Photo by <a href="https://unsplash.com/@olloweb?utm_source=medium&amp;utm_medium=referral">Agence Olloweb</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you noticed how lately most products are focused not so much on improving<em> the product itself</em> but on offering features on top of the product that are enabled by them getting to know <strong>you</strong> as a user.</p><p>What I mean is, we all know that apps like TikTok and Instagram don’t really do any dramatic changes, the goal is not so much to improve on performance or expand functionality, but to gathering all the data they can reach and grab about you and serve you more and more of whatever keeps you in the app. The more interesting bit for me is that, lately, even those that seem like hardware products, like smartphones, have kind of reached the limit of the improvements any human would be actually able to detect and appreciate so now the selling point is — your phone “knows” you and can do more for you, remind you when to stop wasting time when to go to sleep, tell you about your health etc.</p><p>The success of any product today, no matter what it is, relies heavily on the company investing time, effort, and money in getting to know their customers and using that information to retain them and gain new users.</p><p>There are so many tools and frameworks out there that allow you to collect data, analyse it, visualize it, gain insights on users’ behaviour and help you make really data-backed decisions about your business. I was browsing around and chose 5 to compare on few key factors that need to be considered when making the decision which one to go with — <a href="https://snowplowanalytics.com/">Snowplow</a>,<a href="https://analytics.google.com/analytics/web/"> Google Analytics</a>,<a href="https://segment.com/?ref=nav"> Segment</a>,<a href="https://amplitude.com/"> Amplitude</a>,<a href="https://www.rudderstack.com/"> Rudderstack</a>.</p><h3>Data ownership</h3><ul><li><strong>Snowplow — </strong>you own the data and its journey entirely, it is stored on your infrastructure and is stored in a warehouse of your choosing</li><li><strong>Google Analytics</strong> — runs on Google’s infrastructure, stores the data in BigQuery, so you are either forced to use BQ and GCP or sync BQ with your other data warehouse</li><li><strong>Segment</strong> — runs on its own infrastructure and stores the data there, you can sync it with a DB, data warehouse, or any supported destination</li><li><strong>Amplitude</strong> — runs on its own infrastructure and stores the data on its servers, you can export it to the selected destination</li><li><strong>Rudderstack</strong> — you can store your data in your own data warehouse, without having to go through ETL hoops to get it there or use the paid cloud solution</li></ul><h3>Data accessibility</h3><ul><li><strong>Snowplow — </strong>you decide what events to track and want to include in them so you have full access to the raw stream of data</li><li><strong>Google Analytics — </strong>you see the end result of the data already stored in BigQuery, you have no control over the processing and journey of the data</li><li><strong>Segment</strong> — you can use the provided UI to access the collected data or sync it with your storage and review the data there, in either case you don’t really access the raw data</li><li><strong>Amplitude</strong> — you can use the provided UI or connect with a visualization tool, export, and review in another storage, etc</li><li><strong>Rudderstack</strong> — since you are responsible for the implementation to a wider extent you choose where to store and how to access the data</li></ul><h3>Structure of the tracked events</h3><ul><li><strong>Snowplow — </strong>freedom over the types and fields in the events being tracked</li><li><strong>Google Analytics — </strong>generally you need to use a fixed schema with the flexibility to add custom metrics and dimensions but those need to be connected to the known ones in order to make them “collectible”</li><li><strong>Segment</strong> — each message follows a predefined structure of common fields, contexts and customizable fields</li><li><strong>Amplitude</strong> — seems to provide a bit more flexibility in terms of what and how you sent, similar to Snowplow</li><li><strong>Rudderstack</strong> — greater flexibility over the events and properties you choose to track</li></ul><h3>Real-time tracking</h3><ul><li><strong>Snowplow — </strong>supports near real-time analytics and it’s up to you where you store, how you visualize or model your data</li><li><strong>Google Analytics </strong>— in 360, data is refreshed every 4 hours.</li><li><strong>Segment</strong> — supports near real-time analytics by making the collected data available right away on their platform,if you need the data in your warehouse then depending on your plan you can get the data in it from once or twice a day up to 24 times a day</li><li><strong>Amplitude</strong> — supports near real-time analytics by making the collected data available right away on their platform, if you need your data in your own data warehouse you can create a connection that will sync it every 10 mins which is quite good compared to most</li><li><strong>Rudderstack</strong> — supports new real-time analytics</li></ul><h3>Data Enrichments</h3><ul><li><strong>Snowplow — </strong>provides ways for you to enrich your business data with values from external sources like geographical information, weather, currency conversion, event fingerprints, etc</li><li><strong>Google Analytics — </strong>doesn’t seem to allow enrichments in real-time, you can add those bits later by processing the data once it is in BigQuery</li><li><strong>Segment</strong> — does’t provide enrichments in the same way as Snowplow, those can be applied after the collection and storage as post-processing</li><li><strong>Amplitude</strong> — doesn’t offer enrichments, not in the same literal and on the fly sense as Snowplow, there is a solution which seems like a workaround tbh described<a href="https://amplitude.com/blog/enrich-analytics-targeted-segmentation"> here</a>, which involves Segment and Clearbit API</li><li><strong>Rudderstack</strong> — enrichments are available through the transformations you can apply to your events, in those you can<a href="https://www.rudderstack.com/docs/transformations/#external-api-requests"> call external APIs</a> or apply any custom logic to add value to the events you collect</li></ul><h3>Validation and Monitoring</h3><ul><li><strong>Snowplow — </strong>validates the data against the predefined schema and if this fails, the “bad” events can be stored temporarily in a different stream or means of storage so they can be reprocessed or analyzed later. This can serve as a safety net since any implementation issue in the pipeline would not lead to inevitably losing data.</li><li><strong>Google Analytics</strong> — there is no way to keep track of events that fail to process, and no way to reprocess them later, so if there is an issue with your implementation, you’ll be losing data</li><li><strong>Segment</strong> — no way to reprocess failed events in the same granular level as with Snowplow</li><li><strong>Amplitude</strong> — you can validate the events against the schema and configure response to events that don’t match — either ignore, accept or raise a warning/error, you can review the errors for the last 24h and take action on those as well. However, there doesn’t seem to be a way to reprocess the already failed one, just make sure you know how to deal with future events of that type</li><li><strong>Rudderstack</strong> — is the only other one that provides a replay of data</li></ul><h3>Integrations</h3><ul><li><strong>Snowplow</strong> — in addition to the events you can track from your own applications, you can gather data from third-party sources like Airship, CallRail, HubSpot, MailChimp, MailGun, PagerDuty, StatusGator, Unbounce, ZenDesk,<a href="https://docs.snowplowanalytics.com/docs/collecting-data/collecting-data-from-third-parties/"> and others</a></li><li><strong>Google Analytics </strong>— of course, offers seamless integration with many of its own services like Google AdWords, Google AdSense, Google DoubleClick, Google Search Console, Google DataStudio</li><li><strong>Segment</strong> — this is probably where Segment really shines, it offers a. huge variety of<a href="https://segment.com/docs/connections/sources/"> sources</a> and<a href="https://segment.com/docs/connections/destinations/"> destinations</a> you can use out of the box</li><li><strong>Amplitude</strong> — has<a href="https://amplitude.com/integrations"> a pretty wide range</a> of available components you can integrate with</li><li><strong>Rudderstack</strong> — offers<a href="https://www.rudderstack.com/integration/"> a lot of out of the box integrations</a></li></ul><h3>Cost</h3><ul><li><strong>Snowplow</strong> — the most tempting thing for a business is the price — the product itself is open-source and completely free. You need to cover the cost of the data platform components you deploy in your cloud. There is also support and a new service available as a paid option now.</li><li><strong>Google Analytics </strong>— a 360 license starts at around $150.000 a year</li><li><strong>Segment</strong> — quote costly, need a business plan for most moderate to big companies</li><li><strong>Amplitude</strong> — seems to be similar to Segment in the way they tier and price the service</li><li><strong>Rudderstack</strong> — there is free open source code available, along with a paid service which is quite expensive</li></ul><h3>Technical skills</h3><ul><li><strong>Snowplow</strong> — requires more skills and time since you need to be able to set up the whole data pipeline using the tools provided by Snowplow. You can see the code for all available components for tracking, capturing, and storing, and enriching the data in their<a href="https://github.com/snowplow"> GitHub</a> account. This means you’ll need to be way more involved but also that you have a lot more flexibility to use the bits you need in a way that will work for you. The functionality provided is also entirely transparent, you can even edit and contribute to the project, so you’ll know exactly what, why and how things work.</li><li><strong>Google Analytics </strong>— requires minimal setup and gives you all the tools pre-configured out of the box — tracking, storing, presentation interface, scalability, and tracking, which might be ideal for a small startup that just needs to kick things off asap or a team that wants the data but doesn’t have the technical expertise to plan and create a full pipeline.</li><li><strong>Segment</strong> — this one is closer to Google Analytics and requires minimal technical knowledge and understanding to start up</li><li><strong>Amplitude</strong> — another one that needs little technical knowledge, the main work is just setting up connections and configuring ELTs</li><li><strong>Rudderstack</strong> — this is probably the one closest to Snowplow in terms of offering open source components (see their<a href="https://github.com/rudderlabs"> GitHub here</a>) which means you have to option to pick and choose what parts to use and integrate and use them in your systems. If you go with that you will need a lot more technical expertise and time to get it all up and running, although you will have the control and flexibility you’d be lacking with the other solutions.</li></ul><p>It is actually not easy to compare all those 1 to 1, since different tools seem to lean more on different aspects- either tracking, analytics, visualization or ease of use. Snowplow and Rudderstack are more like Ikea, they give you the material and tools you do what you want and need to do with those. If you have the skills and time you can end up with something super useful and robust, if not… you better not start because you’ll just end up with a headache. Amplitude and Segment are focused on providing a more well-rounded and fully managed service where you use their product for everything. A lot of the technical complexities are abstracted away, which can be useful for non-technical people, but you give up control, rely on their availability, support, and you are a bit further removed from your data and how it’s processed and used. Google Analytics is…well a Google product and it’s implicitly understood that it would be most useful if you use exclusively and primarily Google products.</p><p>There are so many more frameworks out there that I did not add in the comparison but some worth mentioning is:</p><ul><li><a href="https://improvado.io/integrations/facebook-pages">Improvado</a></li><li><a href="https://www.pendo.io/">Pendo</a></li><li><a href="https://mixpanel.com/home/">MixPanel</a></li></ul><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1ab713e41e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/user-tracking-and-analytics-tools-comparison-f1ab713e41e5">A Comparison of User Analytics and Data Tracking Tools</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Pitfalls — How Advantages Can End Up Making Your Life Harder]]></title>
            <link>https://medium.com/better-programming/microservices-pitfalls-how-advantages-can-end-up-making-your-life-harder-d0663707bd4?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0663707bd4</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[monolith]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Sun, 22 May 2022 08:52:12 GMT</pubDate>
            <atom:updated>2022-05-23T05:09:11.225Z</atom:updated>
            <content:encoded><![CDATA[<h4>Every trendy technology should be implemented cautiously</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EjPu7xSlWhzlQdUD" /><figcaption>Photo by <a href="https://unsplash.com/@teckhonc?utm_source=medium&amp;utm_medium=referral">T.H. Chia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Microservices have been the way to go for a while now and they offer some undeniable benefits. I am not here to tell you this model is wrong.. no, that would be wild. However, I’ve been on a kick of reading about exceptions to the rules, about the limitations of what we call “best practices” in coding and software architecture. One thing that came up, again and again, was the monolith vs the microservices debate.</p><p>It’s not really a huge discussion, most people recognize the advantages of the microservices approach, but I did come across some interesting points against it or rather risks in the way those are implemented. I have also witnessed a lot of those risks turn into reality and become a burden for the engineers. Like everything in life, the model should be taken with a grain of salt and balanced against the real-world context and limitations as well as the business specifics and goals. So, I wanted to sum up some of the key pitfalls I found and observed myself.</p><p>Let’s first have a look at what are the reasons to move away from a monolith and all the “advertised” benefits of the microservices architecture.</p><h3>What is a monolith architecture and why is it not in anymore?</h3><p>A monolithic application is one where all the code, even if split into logical modules, is considered a single project, often the code lives in a single repository and the build also produces a single deployable, executable artefact. Usually, when talking about this kind of application people think of enterprise applications with these 3 components — a database, a user interface, and a server-side application, although that’s not necessary.</p><p>Well, that sounds good, doesn’t it? There are some obvious <strong>advantages</strong> to this:</p><ul><li><strong>ease of development and deployment</strong> — you have all the code in a single place so reusing the code is easy, testing end-to-end is easy and deploying way less hustle</li><li><strong>performance</strong> — this is often quoted as an advantage of monoliths and it’s true that communication between the front end and back end is more efficient if it doesn’t need to involve calls over the network through HTTP API or any other way. However, for applications where that’s not really critical the argument gets weaker.</li></ul><p>On the other hand, there must be a lot of disadvantages to a monolithic application if that’s not the go-to anymore, right?</p><ul><li><strong>tight coupling</strong> — no matter how hard you try to keep some sort of logical separation in your code, it’s inevitable that you end up with at least somewhat coupled modules.</li><li><strong>higher complexity </strong>— often the monolith repositories turn into a labyrinth for new and even experienced developers. That makes it hard to make changes because the impact of those changes is unclear. Even if the code base is well tested and it prevents most bugs from leaking into production, the time an engineer would take to implement the change and debug any potential test failures would be doubled</li><li><strong>bug impact </strong>— whenever your safe net of tests fails you and a bug does end up in a release, then that would affect the whole application and render an important business service unusable</li><li><strong>slower build and startup times </strong>— since all your code is in one place it’s quite slower to build and often also slower to startup the application</li><li><strong>scaling is difficult </strong>— the architecture kind of pushes you towards vertical scaling since horizontal one requires syncing up instances’ data and that defeats the point of a monolith</li><li><strong>innovation is hard, borderline impossible </strong>— having a single code base usually means a limited number of compatible languages and frameworks, so experimentation and innovation is a nightmare that no one wants to deal with</li></ul><p>Notice the difference in the number of cons vs pros? Well, that’s the reason people have moved away from this model.</p><p>So, you can now preempt what some of the benefits of microservices now are, but let’s sum it up.</p><h3>Why choose microservices?</h3><p>The goal of microservices is to have smaller, single-purpose services which communicate with each other through a REST, RPC or message-based API. Each microservice uses its own database and the exposed API can actually serve multiple other services. This brings a lot of benefits to the development team and the business:</p><ul><li><strong>loose coupling</strong> — each service is a separate code base, that hides the business logic and only exposes an API. Changes in the microservice do not affect any other that communicates with it (if done right and backward compatibility is considered)</li><li><strong>reduced complexity </strong>— for a developer to make a change in one microservice they do not necessarily need to be familiar with the whole system, which consequently reduces dev time</li><li><strong>bug impact </strong>— any issue in production is confined to the specific microservice and all the rest communicating with it can implement mechanisms to deal with that in a reasonable way</li><li><strong>faster build and startup time</strong> — just by reducing the amount of code and complexity</li><li><strong>easier and more efficient scaling </strong>— because every microservice has it’s own database and responsibilities, it can be scaled horizontally way easier. What’s more, with the separation in place you can only scale the bits that turn into bottlenecks instead of the whole system</li><li><strong>easy to innovate and experiment </strong>— following up on the first point — changes are transparent for the other microservices — it’s easy to migrate one microservice to a new framework or language without having to consider compatibility and effect on other modules</li></ul><p>That all sounds good, but microservices are not all rainbows and roses, it’s not a magic bullet. There is still a lot to be taken into account when you go in the direction — both technical and non-technical factors should be considered because otherwise, you can end up with dozens and dozens of very tiny microservices that make your life as a developer a hell.</p><p>Let’s see what are some of those.</p><h3>Microservices pitfalls</h3><h4>Scalability</h4><p>Wait, wasn’t this one of the pros? Yes, it was..and it is…to a point. Because the microservices communicate through the network, they require a more complex setup and rely on the speed of the API they use. This might mean that at some point adding more instances of your service doesn’t result in the expected increase in performance but eventually even the opposite.</p><h4>Bug impact</h4><p>Another advantage that might turn against you. Even though a failing app won’t by definition take down all the rest with it, this doesn’t always mean it won’t affect the ability of the rest to function. This is a pro feature that heavily relies on the design of your system and the goodwill, skills, or memory of the teams responsible for the microservices communicating with the failing one. What I mean is, if you create microservices just for the sake of saying you have a microservice architecture without thinking about how those communicate and what’s the impact of each individual failing, then you might as well keep it all a monolith.</p><p>If service A fails and the rest of the services have no way of reasonably handling a failure in A, then they fail as well and it all just propagates back to the top. Additionally, even if there is a way to do that, it’s entirely up to the developers in that team to remember to handle the failure and do it right. This is great from an engineering perspective — you care only for the bit you develop, however, it might result in more time and few iterations until it’s done right and this might affect the user’s experience.</p><h4>Code tidiness</h4><p>Yes, microservices mean less code in a single repository, but no that doesn’t necessarily mean clean and efficient code. When you have different services being developed and maintained by different teams, you might end up with different languages and frameworks which are not compatible, so you end up rewriting the same code. <strong>Duplication</strong> like this might seem innocent in a couple of services but imagine having important bits of code being rewritten in 3–4–5 ways and then having to make a change in all. The coordination between teams that this will require will increase time to production.. a lot.</p><p>It’s also not ideal to go too extreme in the other direction by creating a<strong> single common lib</strong> for every bit of business logic. This is a good idea, but taken a bit too far might be a problem. You might end up with a library that tries to accommodate slight differences in the requirements of multiple services and with this turn into an overly complicated and hard to maintain project, where the impact of each change is not clear and it’s hard to test…sounds familiar huh? Additionally, imagine having to update all microservices dependencies individually in order to apply a needed change from the library? It will not only take time and effort but also a lot of coordination and calculations where it can go first, then next, what would that mean etc…</p><h4>Extensibility</h4><p>It seems like adding new features in a microservice architecture would be easy…and it can be, but not always. Sometimes, a new fearure’s requirements might be harder to achieve with microservices — either because it involves multiple services and teams that need to now put all their other priorities inline and work together or because in the microservices context this feature would force you to implement workaround and with that add technical debt and unnecessary complexity.</p><h4>Syncing states</h4><p>It’s recommended that each microservice has its own database in order to maintain loose coupling and independence for the dev teams maintaining it. However, what happens if 2 or more services need to be in sync about their view of the world? What happens if A updates its database and B and C don’t?</p><p>Investigating issues across multiple applications and making sense of the timeline is a painful exercise and requires developers to actually know a lot if not all about the implementation specifics of the other apps involved, which defeats the purpose of separation of responsibilities.</p><p>What’s more, the negative impact of spending too much time and effort to mitigate those issues programmatically might overweigh the benefits of having those 3 services as one monolith repo. This comes back to the importance of the design and considering the communication and failure handling not just blindly following the trend for the sake of it.</p><h4>Migrations</h4><p>This one is a kind of amalgamation of a few points mentioned already in a few places, namely — applying changes to all microservices is a time and effort consuming exercise. It’s boring and repetitive and really brings down the spirit of the poor developer tasked with this.</p><p>Changes might involve updating dependencies, logical changes, migrating to a different 3rd party service, deployment, monitoring or alerting mechanism. This is especially important and should really be considered carefully in small companies/teams, which deserve its own section.</p><h4>Company/Team size</h4><p>If an individual team of 3–4 developers needs to support and actively extend more than 10 microservices, I’d go out on a limb and say this will be an issue. That would be an example where you as a team need to weigh good architectural practices and trends vs their practical day-to-day implications. You’ll have to balance your own bandwidth with doing things in a recommended way. If you go ahead and decide to work with 10 microservices, then this might heavily reduce your throughput and slow the business down.</p><p>You might need to compromise on some design decisions in order to give yourself some breathing room. That doesn’t necessarily mean bad code, not when you are making those decisions consciously and with a plan for the future. You could keep some logically-related bits together but maintain loose coupling between the modules in a way that will help you split this up whenever the team and company expand.</p><p>In the end, it’s all about having good reasoning to support your architectural and implementation decisions and making that obvious with your design, code, and documentation. That’s extremely important for the future development of the services and will help guide or motivate future decisions because it’s too often true that the people designing, writing, and maintaining service and all different people at different stages in their careers and often too their time in the company does not overlap. Make sure you can back your decisions and don’t just jump on the current trendy best practices train without considering your specific context.</p><p>Thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0663707bd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/microservices-pitfalls-how-advantages-can-end-up-making-your-life-harder-d0663707bd4">Microservices Pitfalls — How Advantages Can End Up Making Your Life Harder</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DataOps — What Is It And Why Should You Care?]]></title>
            <link>https://medium.com/better-programming/dataops-what-is-it-and-why-should-you-care-68557ba2bf7d?source=rss-97cfe701f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/68557ba2bf7d</guid>
            <category><![CDATA[dataops]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Ivelina Yordanova]]></dc:creator>
            <pubDate>Fri, 13 May 2022 22:12:38 GMT</pubDate>
            <atom:updated>2022-05-14T02:56:22.148Z</atom:updated>
            <content:encoded><![CDATA[<h4>Basic concepts and available tools to achieve the data pipeline you dream for</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EpWSdRu3GXSNRbXf" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral">Sigmund</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So, I realize I am a bit late on this since the concept of DataOps has been around for about as long as I have been in tech but I came across that recently and after reading up on it I thought there might be other people like me whose mind will be blown by this. There are lots of good ideas that can be implemented separately, incrementally and even if you don’t get to a one-button-does it all solution there’s much to be won by following the principles in the framework. What’s more, having the framework literally frames a lot of individual concepts all in one bundle makes individual concepts make more sense and gives you an ideal goal to strive for.</p><h3><strong>What is DataOps then and why does it sound so much like DevOps?</strong></h3><p><a href="https://en.wikipedia.org/wiki/DevOps"><strong>DevOps</strong></a> is a combination of principles for ways of working within an organization, best practices, and tools that help companies develop and deliver software quickly. The aim is to automate as much as possible of the product lifecycle (build, test, deploy etc). Keywords here are <a href="https://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a> (CI) and <a href="https://en.wikipedia.org/wiki/Continuous_delivery">continuous delivery</a> (CD) of software by leveraging on-demand IT resources (infrastructure as code), hence the name — “DEVelopment” + “OPerationS”/IT. This is in a way the practical side or the implementation making the <a href="https://en.wikipedia.org/wiki/Agile_software_development"><strong>Agile</strong></a> methodology possible.</p><p><a href="https://en.wikipedia.org/wiki/DataOps"><strong>DataOps</strong></a> is being described in short as DevOps applied to data, which is a nice summary but it’s not telling much. Everyone that’s ever worked with a more complex system knows that there are more variables going into delivering value from a data product than into a software one. So, let’s dig in a bit deeper. Yes, the goal is the same — delivering value quickly in a predictable and reliable way. However, DataOps is aiming to solve the challenge of not only delivering your data-ingestion-and-transformation jobs, models and analytics as versioned code but also the data itself. It tries to balance agility with governance — one speeds up delivery, and the other guarantees the security, quality, and deliverability of your data.</p><p>In terms of changing the way one thinks about different data pipeline components there are a few highlights I spotted while reading:</p><ul><li><strong>Extract, load, transform (ELT) </strong>— data should be loaded raw, without any unnecessary transformations into your data warehouse or lake. This has the benefit of reducing load times and the complexity of your ingestion jobs. The goal is also to not discard anything that might potentially bring value later, by keeping everything in its original form alongside your transformed and analytics-ready data. In some cases, due to legal reasons, some transformation is required and cannot be avoided, that’s when you’ll see this abbreviation — EtLT. In the same line of thinking, no data is deleted..ever. It is just supposed to be maybe archived in lower cost storage solutions</li><li><strong>CI/CD </strong>— for those who are familiar with DevOps, the new concept here is the concept of life cycling database objects. Modern data platforms such as Snowflake offer some sort of advanced features like time travel and zero-copy clones. Additionally, there are solutions for versioning and branching out your data lake — like<a href="https://lakefs.io/"> lakeFS</a>.</li><li><strong>Code design and maintainability </strong>— it’s all about small reusable bits of code in the form of components, modules, libraries, or whatever the used frameworks offer as atomic code entities. Naturally, each company would build its own repository of these and turn them into a standard for all internal projects. It should be obvious that the code should follow best practices, have standard style and formatting applied. Good documentation is also crucial.</li><li><strong>Environment management — </strong>the ability to create and efficiently maintain both long-lived and short-lived environments from branches is essential in DataOps.</li></ul><p>There are 18 general principles listed in the <a href="https://dataopsmanifesto.org/en/">DataOps manifesto</a> and they do sound a lot like a mix of Agile and DevOps principles, you can read more about those on the <a href="https://dataopsmanifesto.org/en/">official page</a>. Here’s the significant mind shift that needs to happen though to apply all that to a data pipeline — you need to start thinking about your data as a product.</p><h3>How is “Data Product” different?</h3><p>Usually, people would refer to a new piece of work that will deliver value to the business as a ”project”. So, in a way the data pipeline and everything around it supporting data ingestion, consumption, processing, visualization and analysis is a collection of small projects. Instead, though, those should be framed as “products”. Key differences between those are:</p><ul><li>a project is managed and developed by a team for the duration of it and has an end date when it’s delivered. Product, on the other hand, has an owning team supporting it and has no end date attached to it</li><li>a project has a scope and a goal and it might get released a few times until it reaches that goal but once that’s done the project is also considered done. A product on the other hand is something people invest in, it evolves, gets updates, gets reviewed, and constantly improved (in an Agile way)</li><li>a project’s testing is limited to the defined and signed-off scope. A product, on the other hand, has automated unit, regression, and integration tests as part of the release process</li></ul><p>If you look up DataOps the following diagram (or variations of it) will come up. It sums up very well the infinite process of — planning, development, testing, and code delivery. It also hints about the need to collaborate with the business (the product stakeholders) at different stages and to get actionable feedback in order to use it in the next iteration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6J1Tw-JZTL4s6hA35GE2ow.png" /><figcaption>source: <a href="https://www.dataops.live/">https://www.dataops.live/</a></figcaption></figure><h3>Making sense of the sea of tools, frameworks, and languages</h3><p>Generally, a data product involves a bigger variety of technologies than an isolated software product. Those built up naturally over time as different teams of data analysts, data scientists, data engineers, and software developers explore better options to meet the business needs and follow their own wishes to learn and grow in their own careers.</p><p>In any case, either directly or indirectly all tools and frameworks generate some code, at least if all the principles are followed and you have versioning for your configurations and all set up in the same way as for any other software project.</p><p>Additional complexity comes from the system design. Data usually comes from multiple sources and can often move non-linearly through the system, multiple processes may be running in parallel and at different stages, transformations can be applied.</p><p>DataOps tries to simplify this with the concept of a central repository, which serves as a single source of truth for “anything code and config” in your system, usually that’s referred to as the “data pipeline” (which is a bit ambiguous since I usually imagine a straight pipe from source to sink consider the above caveat). If we imagine having that all-knowing repository with automated orchestration of the data and the processes handling it, then releasing a change is just a click away. What’s more, keeping track of who does what and collaborating becomes way easier when every team has visibility of the changes in development and the ones going on at any moment. This reduces potential bugs caused by miscommunication and increases the quality of the resulting data product.</p><p>Let’s look at the moving parts DataOps tries to put in place with this magical repo.</p><h3>Pipelines</h3><p>When talking about pipelines in DataOps, there are 2 possible types we could be referring to:</p><ul><li><strong>Development and deployment </strong>— those are the ones familiar from DevOps. That’s the CI/CD pipeline to build, test, and release a data platform’s containers, APIs, libraries etc.</li><li><strong>Data</strong> — that’s the pipeline orchestrating all the components ( whether it’s scheduled jobs, constantly running web services or else) that actually move the data from location A to location B and apply all the required processing. It’s possible and highly likely that a company would have few of those.</li></ul><h3>Jobs</h3><p>That’s the part with most variables. There are so many options as to:</p><ul><li>what technologies does it use — Snowflake, Airflow, Python, HTTP..</li><li>what triggers it — is it scheduled, does it wait for a condition to be met, does it run constantly</li><li>where it runs — in an on-premise server, in a private cloud, in a third party environment you know little about</li><li>how it handles errors</li><li>what defines success</li></ul><h3>Data Catalogue</h3><p>No matter the amount and types of tools and services orchestrated as part of the pipeline, it’s important that they are capable of adding and understanding metadata. This serves the purpose of being the language in which the software components process the data communication with each other as well as, in the end, being a great source of debugging and business information. It can help you, as a maintainer of the pipeline, identify what data is in your system, how it’s moving through it, and trace and diagnose. It’s also helpful for the business to know what data is available and how to use it.</p><p>There are data cataloging tools promoting machine learning augmented catalogs that are supposed to be able to discover data, curate it, perform tagging, create semantic relationships and allow simple keyword searches through the metadata. ML can even recommend transformations and auto-provision data and data pipeline specifications. However, even with ML, any data catalog is only as good as the data and metadata it is working with. A centrally-orchestrated DataOps pipeline “knows” all about where data is coming from, how it’s tested, transformed, and processed, where it ends up, etc.</p><p>Having quality metadata along with the versioning in your orchestrating repository will also guarantee accountability and better quality of the data itself. It’s important to maintain that not only for the sake of the business value it adds but also for the internal company cultural element of having your stakeholders trust you and what you do and thus creates a better work environment..and happy and calm people work better.</p><h3>Testing</h3><p>A key concept in DataOps is testing. It should be automated and run in different stages before any code goes into production. An important distinction with DevOps is that orchestration happens twice in DataOps — once for the tools and software handling your data and the second time for the data itself i.e for the 2 pipelines described a few paragraphs back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIvbwvkNitmZ6wGNFsXfHQ.png" /><figcaption>source datakitchen: <a href="https://medium.com/data-ops/dataops-is-not-just-devops-for-data-6e03083157b7">https://medium.com/data-ops/dataops-is-not-just-devops-for-data-6e03083157b7</a></figcaption></figure><p>What is missing in the above flow is the complexity of the test stage in DataOps is also doubled. In order to do proper regression and integration testing, you need a representative data set to be selected (which is not a trivial task in itself) and anonymized. What’s more, there are often issues that can really only be caught much further downstream in your pipeline. Therefore for an integration test, you need to have an almost end-to-end setup. This is both a technical and financial challenge — replicating a full pipeline even for a snap moment can be too expensive and hard to achieve. In a world where DataOps is implemented to its purest form this might be possible but in many cases, smaller companies especially, do not really have the resources for this. The goal is rather to use the principles as a guide when you design your system and try to implement the bits and pieces that will bring you the most value and save you the most time, effort, and cost…easy right?</p><h3>DataOps Tools</h3><p>That all sounds good in theory, but how to even begin to implement it? Well, there are tools on the market that claim to work in this space and do-follow those principles, each to a different degree. The bigger ones are:</p><ul><li><a href="https://www.unraveldata.com/dataops/">Unravel</a> — offers AI-driven monitoring and management. It validates code and offers insights into how to improve testing and deployment. It’s for companies that want to focus on optimizing the performance of their pipeline.</li><li><a href="https://datakitchen.io/">DataKitchen</a> — serves more like an add-on on top of your existing pipeline and provides the typical DevOps components like CI/CD, testing, orchestration, and monitoring</li><li><a href="https://www.dataops.live/">DataOps.live</a> — in addition to the DevOps components, dataOps.live provides some elements of the data pipeline like ELT/ETL, modelling, and governance. If the customers use Snowflake, then they can benefit also from the db versioning and branching capabilities</li><li><a href="https://www.zaloni.com/">Zaloni</a> — contrary to the previous two, this one focuses heavily on the data pipeline and delivering all its components of it within one platform. That’s not to say that they don’t offer the DevOps components, they do. It’s a very well rounded tool and is perfect for companies with strict governance requirements</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68557ba2bf7d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/dataops-what-is-it-and-why-should-you-care-68557ba2bf7d">DataOps — What Is It And Why Should You Care?</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>