<?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 Synnada on Medium]]></title>
        <description><![CDATA[Stories by Synnada on Medium]]></description>
        <link>https://medium.com/@synnada?source=rss-9989aaa4833d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2vBSTyP-0RpFtIP0melY2A.jpeg</url>
            <title>Stories by Synnada on Medium</title>
            <link>https://medium.com/@synnada?source=rss-9989aaa4833d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:10:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@synnada/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[Modern Data Stack and the Data Chasm — Part II]]></title>
            <link>https://synnada.medium.com/modern-data-stack-and-the-data-chasm-part-ii-79a1f2a4d25e?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/79a1f2a4d25e</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[modern-data-stack]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 15:47:55 GMT</pubDate>
            <atom:updated>2023-10-20T15:47:55.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LO8c5vWqugo6chbx1azi6A.png" /></figure><h3>Modern Data Stack and the Data Chasm — Part II: A Path to Leaner Data Systems</h3><blockquote><em>This article was originally published on </em><a href="http://www.synnada.ai/blog/modern-data-stack-and-the-data-chasm-part-2"><strong><em>Synnada</em></strong></a><em> on October 20, 2023.</em></blockquote><h3>Emergent Lean Patterns in Data Practices</h3><p>In <a href="https://medium.com/r?url=https://www.synnada.ai/blog/modern-data-stack-and-the-data-chasm-part-1">Part 1</a>, we explored how the expanding data ecosystem led to fragmentation and complexity, thrusting teams into a “data chasm” where they are unable to integrate siloed tools. In Part 2, we focus on pioneering data teams that crossed this chasm, continuing innovation and growth. By studying these real-world cases, we aim to uncover principles for <strong>leaner data systems</strong>.</p><p>The examples chosen for this study are not random — they were selected based on the popularity, longevity and robustness of the solutions deployed. These technology platforms and methodologies have stood the test of time, continuously proving their worth and adaptability despite the dynamic landscape of data ecosystems. Such resilience makes them valuable case studies for identifying lean data practices.</p><p>First, we cover Airbnb’s data story: Amid rapid growth, Airbnb was struggling with an increasingly complex data infrastructure and inefficient workflows. They tackled this challenge by designing and building <a href="https://airflow.apache.org/">Airflow</a>, a foundational solution to develop, schedule, and monitor data pipelines at scale. Next, we explore Uber’s story, which was facing rising logging costs and maintainability hurdles. They simplified their data infrastructure by replacing one of their core infrastructure components, along with all its supplementing tools, with a stronger/more unified technology — resulting in a leaner system. Finally, we discuss Apache Arrow, an industry wide solution that bridges the data chasm created by the explosive growth in big data tooling.</p><p>While we constrain our attention to these specific cases, we may cover other examples like Apache Spark, Apache Kafka, and DuckDB over time in subsequent posts (feel free to suggest others). Let’s examine our first case study.</p><h3>Airbnb Tackling Tooling Disorganization and Complexity</h3><h4>Background</h4><p>Founded in 2007, Airbnb grew from humble beginnings into a hospitality giant serving over 4 million hosts and 1.5 billion guests globally. Airbnb’s data team contributed greatly to this success. However, the path was not without challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*MR1-8SuSQwMbQcMA" /><figcaption>Source: <a href="https://slideshare.net/Work-Bench/scaling-data-science-at-airbnb">https://slideshare.net/Work-Bench/scaling-data-science-at-airbnb</a></figcaption></figure><p>Airbnb formed its data team in 2010. By 2015, the team ballooned to 70 people across 6 groups — massive growth in 5 years. Currently, the estimated team size is around 450. In 12 years, Airbnb’s data team grew by 43,000%!</p><p>Rapid growth strains organizations, and Airbnb was already facing significant data infrastructure challenges in 2014 (maybe even earlier). As the company was still a rapidly scaling startup, solving these challenges quickly became critical if the incredible growth rate were to continue.</p><h4>The Data Chasm</h4><blockquote>Back then we knew so little about the business that any insight was groundbreaking; data infrastructure was fast, stable, and real-time (I was querying our production MySQL database); the company was so small that everyone was in the loop about every decision; and the data team (me) was aligned around a singular set of metrics and methodologies. [<a href="https://medium.com/airbnb-engineering/at-airbnb-data-science-belongs-everywhere-917250c6beba">Source</a>]</blockquote><p>Airbnb’s first, one-person data team used to query production databases directly. As the team grew, they adopted an agile, decentralized approach allowing engineers to build custom tooling tailored to their projects’ goals. By 2015, their now 70-person data team were using a complex and fragmented infrastructure with a myriad of problems:</p><ol><li>Unclear tool ownership led to disjointed workflows spanning siloed systems. Tasks that once took hours now took days.</li><li>Interconnected pipelines evolved into complex hairballs of jobs. Debugging failures was a nightmare.</li><li>New data workers were overwhelming systems designed for niche use cases. General-purpose platforms were lacking.</li></ol><p>Airbnb was hit hard by the “data chasm” trap: Their initial decentralized approach that catalyzed growth became an impediment, now threatening further growth.</p><h4>Crossing the Chasm</h4><p>In 2014, with the data team now 28 people strong, infrastructure engineers realized duct tape wouldn’t suffice amid mounting complexity and a projected 4x growth. The team knew further growth and specialization meant deeper complexity and entanglement unless they reassessed their approach to workflow management and built a robust yet flexible foundation to support their growth.</p><p>Their initial approach resulted in networks of jobs with interconnected dependencies between them. However, these networks of jobs could be “disentangled” into directed acyclic graphs (DAGs) of computational steps. DAG computations and their architectural requirements are extensively covered in the literature, and Airbnb relied on these strong theoretical foundations around DAGs while developing the Airflow platform rather than re-inventing the wheel.</p><p>Leveraging first principles and sound software engineering, Airbnb engineered Airflow as a modular, enduring workflow management solution offering high-level abstractions that simplify workflow authoring, scheduling, monitoring and logging. <strong>Airflow’s scalable, flexible and extensible architecture enabled Airbnb to cross the data chasm and continue their trajectory of data-driven innovation.</strong></p><h3>Uber Wrestling with Scaling Issues Around Logging</h3><h4>Background</h4><p>Uber, pioneering ride-hailing since 2009, operates in 70 countries and 10,500 cities globally with over 131 million monthly active users.</p><blockquote>With Uber’s business growing exponentially (both in terms of the number of cities/countries we operated in and the number of riders/drivers using the service in each city), the amount of incoming data also increased and the need to access and analyze all the data in one place required us to build the first generation of our analytical data warehouse. [<a href="https://www.uber.com/en-TR/blog/uber-big-data-platform/">Source</a>]</blockquote><p>In its early days, Uber’s data needs were met by a few databases. But with exponential business and data volume growth, they constantly had to improve/iterate on their data infrastructure. By 2015, they were relying on the ELK (<a href="https://www.elastic.co/">Elasticsearch</a>, <a href="https://www.elastic.co/logstash">Logstash</a>, <a href="https://www.elastic.co/kibana">Kibana</a>) stack for logging, mainly focusing on observability use cases. With Elasticsearch’s document model, they could easily accommodate their ever-changing data needs — essential in such a rapid environment.</p><h3>The Data Chasm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wben_1YfKgaXU8Gn" /><figcaption>Source: <a href="https://www.youtube.com/watch?v=Zl58abosobk&amp;t=3s">Uber Tech Day: Leveraging Elastic for Logging and Search</a></figcaption></figure><p>Fast forwarding to 2017, logging infrastructure was spanning thousands of Kafka topics, storing 2.5PB of data, and ingesting at 5GB/s. This incredible growth was fueled by increases in both data users and use cases, like demand forecasting, ETA predictions and driving usage. Meanwhile, microservices exploded to over 3000, each producing more log volume. This volume was now straining the ELK stack, ultimately hindering debugging and analytics efforts. Challenges included:</p><ul><li><strong>Operational Complexity</strong>: The fragmented ELK deployment required constant resharding and rebalancing across 50+ clusters per region, consuming significant engineering resources.</li><li><strong>Hardware Costs</strong>: Elasticsearch’s indexing requirements consumed significant hardware resources, making it expensive to scale.</li><li><strong>Performance Bottlenecks</strong>: More than 80% of queries were aggregation queries, and Elasticsearch was not optimized for fast aggregations across large datasets.</li><li><strong>Schema Conflicts</strong>: Elasticsearch’s schema enforcement led to thousands of daily type conflicts and mapping explosions, reducing developer productivity. While Elasticsearch can be configured in a schema-agnostic fashion, this probably would have required significant rearchitecting resulting in migration costs/complexities, and may have exacerbated the aforementioned problems.</li></ul><p>Uber hit the “data chasm” when the initial benefits of the ELK approach started turning into liabilities at scale. The system that once enabled growth was now a bottleneck inhibiting it.</p><h4>Crossing the Chasm</h4><p>Fundamentally, data engineering solutions should aim to maximize added value per unit cost spent. Uber’s ELK stack, being a search infrastructure at its core, was overextended for analytics use cases — causing costs to rapidly outpace the added value.</p><p>Recognizing this mismatch, Uber sought a solution better optimized for analytical workloads with strong unit economics. At this time, the industry already started seeing positive results applying column-oriented databases for analytics workloads — and the concept was previously explored in academic work in the likes of <a href="https://en.wikipedia.org/wiki/C-Store">C-Store</a> and <a href="https://en.wikipedia.org/wiki/MonetDB">MonetDB</a>, which were shown to provide order-of-magnitude efficiency gains. Realizing this, Uber leaned towards <a href="https://clickhouse.com/">ClickHouse</a>, whose architecture followed the footsteps of these early technologies and was well-suited to Uber’s needs.</p><p>ClickHouse’s column-oriented processing offers high-performance ad-hoc analytics at scale. Furthermore, its efficient JSON ingestion and manipulation features enables a schema-agnostic logging architecture that can adapt to evolving data over time. This avoided the scaling and cost drawbacks of attempting to re-architect Elasticsearch into a schema-agnostic system.</p><p>A purpose-built architecture leveraging ClickHouse to meet their evolving analytics requirements was a promising vehicle for Uber as they sought to cross the data chasm. Advantages included:</p><ul><li>10x higher ingestion throughput per node over Elasticsearch.</li><li>50% lower hardware costs ingesting more data.</li><li>Increased operational efficiency and reduced overhead.</li></ul><p><strong>By optimizing for value per unit cost spent, Uber successfully crossed the chasm</strong> with ClickHouse — enabling continued analytics innovation with an architecture positioned for scale, performance, and efficiency.</p><h3>Apache Arrow Bridging the Interoperability Gap</h3><h4>Background</h4><p>The big data era of the 2010s was akin to a “Cambrian Explosion” of data tools. From <a href="https://en.wikipedia.org/wiki/Apache_Hadoop">Hadoop’s</a> distributed data storage to Spark’s in-memory computation and <a href="https://pandas.pydata.org/">Pandas</a> for Python-based dataframe manipulation, the ecosystem was teeming with specialized life forms. Companies like <a href="https://www.databricks.com/">Databricks</a>, <a href="https://www.cloudera.com/">Cloudera</a>, and <a href="https://www.datastax.com/">DataStax</a> were at the forefront of this revolution, each offering unique solutions optimized for specific tasks. This diversity fueled innovation and growth, allowing organizations to tailor their data analytics capabilities precisely.</p><h4>The Data Chasm</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*XDOPfhOX5amTSJ_v" /></figure><p>However, this biodiversity of tools came at a steep cost. Each tool had its own internal data representation, making data interchange a cumbersome and resource-intensive task. As Wes McKinney, the creator of Pandas and a key contributor to <a href="https://arrow.apache.org/">Apache Arrow</a>, points out: “<em>The computational overhead from data serialization and deserialization was becoming a bottleneck.</em>” The very diversity that had been an asset was turning into a liability, creating a data chasm filled with inefficiency and complexity.</p><h4>Crossing the Chasm with Arrow</h4><p>Recognizing the root cause of the problem as the lack of a universal data interchange format, the team behind Apache Arrow took a first-principles approach to find a solution. They turned to foundational research in the field of database management systems, particularly the work done on MonetDB/X100. These papers demonstrated that vectorized, columnar in-memory processing could lead to order-of-magnitude performance improvements in a vast space of use cases.</p><p>Inspired by this scientific insight, Apache Arrow took the road to be a “universal columnar memory format” optimized for analytics and compatible across multiple languages and platforms. As Jacques Nadeau, a key contributor to Apache Arrow, states: “<em>Arrow is designed to be the underpinning of the analytics big data ecosystem for the next decade.</em>”</p><p>The project incorporates the following key principles:</p><ul><li>Columnar Format: Building on prior academic research, Arrow leverages columnar storage to enable more efficient analytics operations.</li><li>Language and Platform Agnosticism: The Arrow ecosystem provides libraries for multiple languages to realize seamless data interchange in practice.</li><li>Zero-Copy Reads: Arrow supports zero-copy reads to significantly reduce the computational overhead associated with data movement. Zero-copy reads are one of the key causes of the aforementioned performance improvements.</li></ul><p>By grounding their solution in well-established research and taking a first-principles approach, Apache Arrow aspires to bridge the “data chasm” that had been created by the Cambrian explosion of data tools. It is turning the ecosystem’s diversity from a liability back into an asset, setting a new standard for efficient, scalable data processing.</p><p>Apache Arrow, in a short period of time, is poised to become a cornerstone in the <em>modern</em> data stack, enabling organizations to escape the “data chasm” and continue their trajectory of data-driven innovation. Its universal columnar data format is being adopted by a range of big data tools, possibly setting a new standard for data interchange.</p><h3>Introducing the Lean Data Stack</h3><p>Studying these successful “crossing the chasm” stories reveals common threads that catalyze success. Rather than chasing trends (e.g. creating an “Ops” layer with each hype), these teams focused on root causes and engineered durable solutions by asking foundational questions first. Their approaches reflect that even though the hype cycle favors the early bird, only thoughtful foundations deliver in the long haul.</p><p>Another theme is the pursuit of economic yet capable systems aligning costs tightly with the added value. Rather than overbuilding lavishly, they weighed expenses like compute, storage and bandwidth against needs for performance, speed and flexibility. Ultimately, they were trying to justify whether their data engineering complexity delivers enough additional insights per dollar spent. This pragmatism provides guidance: Anchor architectures to measurable value per dollar.</p><p>Beyond foundations and economics, these solutions also focus on composability through modularity, capability depth, and standards. Rather than monolithic structures, these teams built flexible systems from simple, compatible components with clean interfaces on top of extensible cores. Such extensible cores allow third parties to enhance and expand in unforeseen ways, letting users dynamically adapt by piecing together elements as necessary.</p><p>Distilling lessons from these pioneers, we put forth the initial tenets of the <em>Lean Data Stack</em> — a paradigm change from today’s <em>Modern Data Stack</em>. The vision is to architect simple yet powerful data systems optimized for longevity, thrift, and flexibility. This refined methodology is defined by the following principles:</p><ul><li><em>Foundational:</em> Build sound foundations focused on durable solutions rather than ephemeral trends. Engineer resilient systems positioned for the long haul.</li><li><em>High-surplus:</em> Align infrastructure costs tightly to the value gained per dollar spent. Pragmatism over lavishness.</li><li><em>Compoundable:</em> Favor modular components with capability depth that can be composed together for complex capabilities. Enable agility through interchangeable solutions based on common standards.</li></ul><p>While these principles are just an initial framing, we believe they capture the essence of the Lean Data Stack. There is still much left to uncover about what makes data systems and architectures <em>lean</em>. By taking an iterative approach, analyzing additional case studies and investigating practical examples, we aim to continue adding depth to the Lean Data Stack concept — equipping it to meet future data challenges.</p><p>In the next article, we will explore how Synnada applies these concepts as we build next-generation data infrastructure technology. By embracing foundational, high-surplus, and compoundable design, Synnada is engineering a solution that aims to help organizations bypass the data chasm.</p><h3>References and Remarks</h3><p>[1] The Airbnb engineering team provided an in-depth look at Airflow’s origins and evolution <a href="https://medium.com/airbnb-engineering/airflow-a-workflow-management-platform-46318b977fd8">in this Medium</a> post. Maxime Beauchemin, Airflow’s original creator, also explained key technical details in <a href="https://maximebeauchemin.medium.com/airflow-and-the-future-of-data-engineering-a-q-a-266f68d956a9">this blog</a> and <a href="https://www.youtube.com/watch?v=Fvu2oFyFCT0">this video</a>.</p><p>[2] <a href="https://www.youtube.com/watch?v=Zl58abosobk">This YouTube video</a> by Uber engineer Hua Wang covers how Uber utilized the ELK stack and the challenges they faced at scale.</p><p>[3] The Uber engineering team outlined their ClickHouse implementation journey and how ClickHouse’s columnar architecture proved better optimized for Uber’s analytical workloads in <a href="https://uber.com/en-US/blog/logging/">this blog post</a> and <a href="https://presentations.clickhouse.com/meetup40/uber.pdf">presentation</a>.</p><p>[4] <a href="https://www.dremio.com/blog/origin-and-history-of-apache-arrow/">This post</a> by Dremio provides background on the history and goals of Apache Arrow.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/samican-tandogdu/">Sami Can Tandogdu</a>, COO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79a1f2a4d25e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modern Data Stack and the Data Chasm: Part I]]></title>
            <link>https://synnada.medium.com/modern-data-stack-and-the-data-chasm-part-i-b1c4994c091b?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1c4994c091b</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[modern-data-stack]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 17:01:49 GMT</pubDate>
            <atom:updated>2023-09-13T17:01:49.746Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlU-TxTJ8XEadFMIZ6X44w.png" /></figure><h3>Modern Data Stack and the Data Chasm — Part I: Emergence of Complexity in Data Systems</h3><blockquote><em>This article was originally published on </em><a href="https://www.synnada.ai/blog/modern-data-stack-and-the-data-chasm-part-1"><strong><em>Synnada</em></strong></a><em> on September 11, 2023.</em></blockquote><h3>State of the Data Market</h3><p><strong>Today’s data teams are overwhelmed by a plethora of poorly integrated technologies</strong>, which have been accumulated over the years due to buying into hype, investing in half-baked solutions, and succumbing to FOMO on the latest –yet unproven– niche innovations. Moreover, many have relinquished control of their architecture to vendors who prioritize selling “futures” rather than addressing fundamental issues. What’s left is a monstrous (modern!?) stack of mismatched parts (or pokemons [<a href="#7bb5">1</a>]): Open source and proprietary, new and old, best-of-breed and cheap imitations — all cobbled together with little design or governance in mind.</p><p><strong>No one sets out to build such a mess on purpose.</strong> Rather; an excess of choice in the data marketplace, rapid hype cycles, fear of lock-in to any single vendor’s agenda, decentralized buying across groups and willingness to buy into futures over fixing the present leads to an increasingly uncoordinated technology sprawl. Alone, each new tool seems like a reasonable quick fix or experiment, but they collectively end up forming a <a href="https://en.wikipedia.org/wiki/Gordian_Knot">Gordian knot</a> of complexity. This complexity has its roots in the ever expanding nature of the data market, a phenomenon we must understand to navigate the challenges it poses.</p><h3>Lift-off: Multidimensional Expansion</h3><p><strong>Expansion in the data ecosystem is multidimensional and self-perpetuating</strong>. One dimension is the type of data we utilize, which is driven by both supply-side capabilities (we can now capture and provide more data about everything) and demand-side forces (data consumers wanting more from data teams). Structured, unstructured, time-series, geospatial, event and even multi-modal data are all growing exponentially — each with its unique properties and applications. This growing versatility of available data and its potential to generate value across various fields, from business intelligence and marketing analytics to scientific research and urban planning, continuously expands the universe of use cases and applications. As we continue to leverage data in increasingly sophisticated ways, the demand for different/new kinds of data also grows, which forms a positive feedback loop and further stimulates the data market’s seemingly endless expansion.</p><p>In tandem with the expansion in data types, the types of databases used to store, retrieve, and manage data have also diversified. For instance, traditional structured data are best handled by relational databases like <a href="https://www.postgresql.org/">PostgreSQL</a>, while unstructured data have found their niche in NoSQL databases like <a href="https://www.mongodb.com/">MongoDB</a>. Time-series data, central to IoT applications and financial analyses, led to the rise of specialized databases like <a href="https://www.influxdata.com/">InfluxDB</a>. Event data, crucial for real-time analytics and application monitoring, are managed efficiently by message brokers like <a href="https://kafka.apache.org/">Kafka</a>. Development of such dedicated technologies underscores the breadth and diversity of data storage and management solutions resulting from the expansion in data types.</p><p>Cascading effects of this expansion do not stop at databases. The rapid proliferation of data types and corresponding databases have fostered the evolution of middleware technologies too. These include ETL tools like <a href="https://www.talend.com/">Talend</a> that integrate disparate databases, data processing frameworks like <a href="https://spark.apache.org/">Apache Spark</a> that handle large-scale data processing separately from databases, and data cataloging tools like <a href="https://www.alation.com/">Alation</a> that provide a collaborative platform for data discovery. These technologies form a new dimension of growth, the “Middleware Matrix”, encompassing an array of solutions designed to connect, integrate, and manage the myriad databases emerging from the data types expansion.</p><p>Alongside the Middleware Matrix, the growing diversity of data types is fueling the development of an array of orthogonal applications. For example, structured data underpin the creation of CRUD applications vital to web development. Streaming data has led to the emergence of Application Performance Monitoring (APM) applications like <a href="https://www.datadoghq.com/">Datadog</a>, <a href="https://www.splunk.com/">Splunk</a> and <a href="https://www.dynatrace.com/">Dynatrace</a>, crucial for real-time system monitoring. More recently, vector databases are now facilitating Large Language Model (LLM) applications, unlocking new possibilities in natural language processing. Each new application contributes to an “Application Area” dimension, adding another layer of complexity to the expanding data market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yOsRjJ_nvn7N63hW" /><figcaption>Figure 1: Evolution of Data and AI Space from 2012 to 2023, <a href="https://mattturck.com/mad2023/">by Matt Turck</a></figcaption></figure><p>In conclusion, the multi-dimensional expansion of the data market is driven by the growth of data types and infrastructure, the evolution of middleware technologies, and the proliferation of orthogonal applications. Each dimension feeds into and enriches the others, collectively shaping a rapidly expanding and dynamic data market. This expansion presents a rich array of opportunities, but it also poses significant challenges, requiring organizations to adopt a strategic and pragmatic approach to navigate their way in this complex data ecosystem.</p><h3>Fragmentation: Hitting the Data Chasm</h3><p><strong>In an effort to serve the ever-growing set of needs, the data market fragments as it expands.</strong> However, we are now witnessing this fragmentation curtail the maturity of the market [<a href="#e4a8">2</a>][<a href="#045c">3</a>][<a href="#0a08">4</a>] — value creation stalls as dissemination of the technology plateaus. The key insight is that even though tech market fragmentation is inevitable, it can (and must) be actively managed to prevent stalling maturity. Unchecked, fragmentation can lead to missed opportunities and an inability to fully capitalize on innovations. To illustrate this point, let’s draw parallels with the cybersecurity ecosystem where the sprawling of tools is not only a natural occurrence but a necessity.</p><p>In cybersecurity, organizations invest in a multitude of tools to mitigate or manage the ever-evolving risks that emerge from their IT investments. Given the segregated duties across dedicated teams and consequential risks of procuring large numbers of security devices from a single vendor, cybersecurity finds strength in its siloed nature. Since a single department or leader often lacks the necessary perspective to optimize at the macro level, the fragmentation of tools seems justified as the landscape continues to complexify.</p><p>In the data ecosystem, while one may argue for certain advantages fragmentation brings, the underlying dynamics are not really analogous to those in cybersecurity. Even though organizations tend to invest in a new type of database for each new type of data, spreading data across regions, devices, and databases; <strong>data inherently generates more value when integrated.</strong> Many data teams have moved away from data silos for this very reason — in contrast with cybersecurity teams who see silos as a way of mitigating risk and perceive them essential. The lens through which data teams look at their systems is predominantly one of engineering costs and business value, rather than risk.</p><p>Visualize the data ecosystem’s demand-side, i.e. organizations utilizing data tooling, as a bell curve. At one extreme, we have small teams using only several tools, such as:</p><ul><li>A gaming company using <a href="https://firebase.google.com/">Firebase</a>, <a href="https://cloud.google.com/bigquery">BigQuery</a> and <a href="https://cloud.google.com/looker">Looker</a> for their analytics workflows,</li><li>A SaaS company using <a href="https://prometheus.io/">Prometheus</a> and <a href="https://grafana.com/">Grafana</a> for observability,</li><li>Companies that opt for special-purpose, ready-to-use solutions, like <a href="https://www.datadoghq.com/">Datadog</a> for APM [<a href="#671f">5</a>].</li></ul><p>As we move to the other extreme, we see large teams with hyper-specialized needs, met by 50+ tools. Tooling fragmentation depends on the maturity of the team: Traditional enterprises tend to use a mixture of core tech/middleware and special-purpose applications, but when we move into the realm of tech giants (e.g. FAANG/MATANA), we start encountering platform engineering teams that deconstruct these applications and reconstruct them in the most cost-effective and customized way for that organization.</p><p>However, in the heart of this distribution, the so-called “fat belly of the market,” midsize teams find themselves facing a peculiar phenomenon: As their data needs grow, they quickly need to leap from using 2–4 tools to wrestling a staggering 15–20. This sudden expansion triggers a surge in integration and alignment challenges, exacerbated by inadequate budgets and a talent market that falls short of meeting the growing demand. These teams often resort to employing new tools in an attempt to alleviate system complexity, inadvertently plunging into a vicious cycle: In an effort to solve tool complexity problems, they procure more tools, ending up compounding the issue and entrapping themselves in a “data chasm”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*DAZ6YaTUja_DUMQqwd_5vA.png" /><figcaption>Figure 2: The seemingly paradoxical data chasm challenging mid-size companies.</figcaption></figure><p>From the perspective of vendors and venture capitalists, this vicious cycle mirrors a flywheel effect, driving rapid startup growth. <strong>However, this viewpoint tends to overlook the escalating problems on the end-user side, where a few individuals are left grappling with the needs of a fairly large company using an unwieldy array of tools.</strong></p><p>As the data market relentlessly expands and fragments, the ensuing complexity and cost of managing data intensifies for all data teams. Particularly affected are the midsize teams, entrapped in a vast data chasm and grappling with the challenge of charting a path out. Nevertheless, certain trailblazing organizations have succeeded in crossing this chasm, extracting value without further deepening their predicaments. In the next part, we will go over some case studies, look at how these pioneering companies deciphered <strong>lean data methodologies</strong> to navigate the data chasm.</p><h3>References and Remarks</h3><p>[1] Anyone remember “<a href="https://pixelastic.github.io/pokemonorbigdata/">Is it Pokemon or Big Data?</a>”?</p><p>[2] Wes McKinney’s <a href="https://wesmckinney.com/blog/looking-back-15-years/">blog post</a> looks back on the technical evolution of the big data ecosystem over 15 years.</p><p>[3] Benn Stancil likens this fragmentation to <a href="https://benn.substack.com/p/gerrymandering">gerrymandering</a>.</p><p>[4] This <a href="https://erikbern.com/2021/07/23/what-is-the-right-level-of-specialization.html">blog post</a> and <a href="https://twitter.com/bernhardsson/status/1417664482776690692">tweetstorm</a> by Erik Bernhardsson, CEO of Modal, discusses the data ecosystem’s natural tendency to fragment and the right level of specialization.</p><p>[5] Such solutions can be thought of as wrapped, turnkey versions of core data technologies and the middleware matrix. An APM solution, for example, could be abstracted as a TSDB coupled with solid data processing capabilities; a CRM solution can be thought of as a SQL DB with workflows.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/samican-tandogdu/">Sami Can Tandogdu</a>, COO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1c4994c091b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Windowing Queries in Stream Processing]]></title>
            <link>https://synnada.medium.com/running-windowing-queries-in-stream-processing-93068d3a5?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/93068d3a5</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 16:34:42 GMT</pubDate>
            <atom:updated>2023-08-18T04:13:08.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppQWArJ-sgdeVx5YDmH-ZQ.png" /></figure><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/running-window-query-in-stream-processing"><strong>Synnada</strong></a> on August 16, 2023, and is part of our ongoing series on streaming SQL engines and advanced join algorithms. In previous posts, we discussed techniques like <a href="https://www.synnada.ai/blog/probabilistic-data-structures-in-streaming-count-min-sketch"><strong>Probabilistic Data Structures in Streaming: Count-Min Sketch</strong></a><strong>, </strong><a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>General-purpose Stream Joins via Pruning Symmetric Hash Joins</strong></a>, and <a href="https://www.synnada.ai/blog/sliding-window-hash-join-swhj"><strong>The Sliding Window Hash Join Algorithm</strong></a> that serve as building blocks. The concepts discussed in this series are implemented in Apache Arrow/DataFusion, which has a bunch of other cool features we haven’t talked about yet.</blockquote><p>Most common use cases in time-series data involves windowing the data in some way or another. Many data processing frameworks and/or languages, including standard SQL, define windowing operators to support such use cases. Efficiently running such operators is an interesting (and surprisingly quite non-trivial) area of engineering, especially when we consider it as a milestone towards achieving the Kappa architecture — where one utilizes a unified compute engine that can handle both batch and streaming datasets.</p><p>In this blog post, we take a first step into this topic by analyzing the circumstances under which window queries can be run in streaming data applications without breaking the pipeline; i.e. in an on-line manner without breaking the stream. In other words, if we can calculate the window function results incrementally without scanning the entire input, we say that the window function is streamable or pipeline-friendly.</p><h3>Background</h3><h3>Context: Streaming Query Execution</h3><p>Before running a query, a query execution engine builds a <em>physical plan</em> that breaks down the query into a sequence of low-level executors/operators that compose together to compute what is described by the query. As the query runs, data flows between these operators and the engine incrementally builds/computes the final result in a pipelined fashion. If any of the executors/operators break the pipeline (meaning, it needs to see/scan all its input data before generating any result), the engine can not run the query in streaming/long-running use cases involving unbounded data sources. Therefore, our aim is to generate streaming-friendly physical plans whenever it is theoretically possible to do so. This blog post analyzes streaming execution support for window functions from this perspective.</p><h3>Context: SQL Window Functions</h3><p>A <a href="https://en.wikipedia.org/wiki/Window_function_(SQL)"><strong>window function</strong></a> is a function that uses values from one or multiple <a href="https://en.wikipedia.org/wiki/Row_(database)">rows</a> to return a value for each row. The rows used by the window function to generate its results is determined by the <strong>window frame</strong> clause, which has the following syntax in SQL:</p><pre>{ RANGE |ROWS |GROUPS } frame_start [ frame_exclusion ]<br>{ RANGE |ROWS |GROUPS } BETWEEN frame_start AND frame_end [ frame_exclusion ]</pre><p>where the prefix { RANGE | ROWS| GROUPS } determines the mode for specifying the window frame boundary. As an example, window frame ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING uses the previous row, the current row and the next row to calculate the result for every row; e.g. the 2nd row uses rows 1,2,3, the 3rd row uses rows 2,3,4 and so on.</p><p><strong>Remark:</strong> For the purposes of this blog post, the window frame mode doesn’t make a difference. Therefore, we will use the ROWS mode in all of the examples henceforth.</p><p>Any data ordering requirement for the window function is specified by an optional ORDER BY clause. If we want to calculate the sum of last (let’s say, according to time) ten sales, we can use the following window expression in a SQL query:</p><pre>SUM(sale) OVER(<br>  ORDER BY ts ASC<br>  ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>)</pre><p>Finally, an optional PARTITION BY clause splits the input table into partitions (groups) based on the PARTITION BY expression. Window functions perform calculations for each such partition independently, allowing us to aggregate data within each partition separately. Effectively, a PARTITION BY clause divides the input table into multiple tables, each table containing the same PARTITION BY expression values. Then, the window expression sans the PARTITION BY clause is run on each “table” independently.</p><p>For example; if we were to calculate the sum of last (let’s say, according to time) ten sales for every country, we can use the following SQL query:</p><pre>SELECT *, SUM(sale) OVER(<br>  PARTITION BY country<br>  ORDER BY ts ASC<br>  ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>)<br>FROM sales_table</pre><p>where we chose to denote our input table with sales_table. If this table were to contain the following rows,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*D28H826hiA7QN9GM3M7h-A.png" /></figure><p>this query would work as if the input table were first split into mutually exclusive subsets, with each subset consisting of distinct country values, as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*xnfqd6Ss-FH5Llzi4M29rg.png" /></figure><p>Then, we would get a final result as if the following partitition-less query was executed for each partition separately:</p><pre>SELECT *, SUM(sale) OVER(<br>  ORDER BY ts ASC<br>  ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>)<br>FROM sales_table</pre><p><strong>Remark:</strong> For the purposes of this blog post, the exact window function in question (here, SUM) is not important. Therefore, we will use the SUM window function in all of the examples henceforth.</p><p>The final result would be the following table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*csTdxfYdYuEHNl4xGhWmFg.png" /></figure><p>Typically; if a window query can generate its results incrementally as it scans its input, the output ordering of the window query will reflect the ordering of its input. However, this is not a strict requirement as long as implementations are concerned; a query execution engine may split table into multiple partitions and then merge these results without considering their original order [1]. Hence, the following result would also be valid:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*pPsh29--GqkLi8oFDnGAow.png" /></figure><p>If one expects a specific output ordering for a window query, one should explicitly impose that ordering via a top-level ORDER BY clause.</p><h3>Streaming Window Function Execution</h3><p>In this section, we will analyze window specifications from the lens of streamability. In other words, we will analyze different kinds of window specifications and discuss whether it is possible to execute queries involving such windows without breaking the data processing pipeline.</p><p>In all of our examples, we will assume that the input of the windowing operator in question is a table named <strong>source</strong>. Schema and example data for the table <strong>source</strong> can be found below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*LLCVpUTW2l2wnQtKV4DqfA.png" /></figure><p>Furthermore, assume that the table <strong>source</strong> satisfies the ordering (ts ASC) as well as the ordering (a ASC, b ASC). Streaming support for window functions highly depends on data ordering, so this assumption will come into play multiple times during our analyses.</p><p>We will analyze the streamability of windowing operations under two main cases:</p><ul><li>When a window query doesn’t contain a PARTITION BY clause in the specification,</li><li>When a window query contains a PARTITION BY clause in the specification.</li></ul><h3>Case 1: Window specification doesn’t contain a PARTITION BY expression</h3><p>In this case, we have window expressions of the following form:</p><pre>function_name ( args ) **OVER** (<br>    ORDER BY &lt;expression&gt; [&lt;direction&gt;] [, &lt;expression&gt; [&lt;direction&gt;] ...]<br>    { RANGE | ROWS | GROUPS } BETWEEN frame_start AND frame_end<br>)</pre><p>For a more in-depth syntactic specification as well as a general discussion of SQL window functions, see [2].</p><p>Consider the following expression as an example:</p><pre>SUM(c) OVER (<br>  ORDER BY ts ASC<br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>This windowing operation computes a sum value for each row in the table according to its window frame clause. The expression ORDER BY ts ASC describes the ordering requirement for this windowing operation. Naturally, the windowing operator will expect its input to satisfy the ordering requirement specified by this ORDER BY clause. Hence, for a window specification to be streamable, we have the following condition:</p><blockquote><em>Under a non-composite ordering requirement (i.e. an ordering requirement involving a single expression), the input of the windowing operation should satisfy the ordering requirement as specified by the </em><em>ORDER BY clause. In our example, the input ordering should satisfy </em><em>ts ASC.</em></blockquote><p>Next, let’s turn our attention to the window frame itself. The table below shows which rows are necessary to compute the sum value for each row in our table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*laNCikNaUDd50xmedbiITQ.png" /></figure><p>As can be seen from this table, our specific example lends itself to computing/finalizing the window function result for any given row whenever data for the subsequent row is received. This motivating example leads us to pose our next condition for streamability:</p><blockquote><em>The window frame shouldn’t end with </em><em>UNBOUNDED FOLLOWING. When the frame ends with </em><em>UNBOUNDED FOLLOWING, we need to see the whole data in order to compute/finalize our results.</em></blockquote><p>Now, consider the case where more than one column/expression is used in the ORDER BY clause, such as the expression below:</p><pre>SUM(c) OVER(<br>  ORDER BY a ASC, c ASC <br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>This windowing operation expects its input to satisfy the ordering (a ASC, c ASC). However, remember that its input (i.e. table source) is ordered by (a ASC, b ASC). Does this mean all is lost? Thankfully, no — the windowing operator can actually buffer up rows until a new value of a is received and avoid breaking the pipeline. In our example, where we start with $a=0$, we would be buffering the following rows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*PF_bZKWLEknNnldkOBH1AA.png" /></figure><p>Then, we can sort this section according to the finer c ASC requirement, which turns the section above to following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*NGGIgREJ1zhniAv7FilesQ.png" /></figure><p>Now, window function results can be calculated using this new “sub-table”. Note that this algorithm effectively changes the input ordering of the windowing operator from (a ASC, b ASC) into (a ASC, c ASC). Note that this responsibility can be delegated to an external auxiliary operator, which itself would be streaming-friendly.</p><p>Generalizing our learnings, we can pose the following streamability condition for windowing operations with lexicographical ordering requirements:</p><blockquote><em>The leading ordering requirement (the first ordering requirement) and the actual leading ordering (the first expression specifying the existing input ordering) should match [3].</em></blockquote><p>Note that this condition is actually a generalization/relaxation of our first condition rather than a new, independent condition.</p><h3>Summary</h3><p>That’s it! We can now summarize our findings for the case we focused on: When a window query doesn’t have a PARTITION BY clause, streamability requires the following two conditions:</p><ul><li>The window frame shouldn’t end with UNBOUNDED FOLLOWING.</li><li>The leading ordering requirement should match with the actual leading ordering of the input [3].</li></ul><p><strong>Remark:</strong> In analysis above, we stated that converting ordering (a ASC, b ASC) into ordering (a ASC, c ASC)is stream-friendly. This statement is only true as long as the common prefix between existing and required orderings (in our case a) isn’t the same for the entire stream, and changes frequently enough (in practice). Since we need to buffer data until we receive a new value for the common prefix; if this value never changes, we would need to scan/buffer the entire stream.</p><h3>Case 2: Window specification contains a PARTITION BY expression</h3><p>In this case, we have window expressions of the following form:</p><pre>function_name ( args ) **OVER** (<br>    PARTITION BY &lt;expression&gt; [, &lt;expression&gt; ...]<br>    ORDER BY &lt;expression&gt; [&lt;direction&gt;] [, &lt;expression&gt; [&lt;direction&gt;] ...]<br>    { RANGE | ROWS | GROUPS } BETWEEN frame_start AND frame_end<br>)</pre><p>Let’s start our analysis through the following windowing operation:</p><pre>SUM(c) OVER(<br>  PARTITION BY a <br>  ORDER BY b ASC <br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>For each partition, which consists of distinct a values, the window function will be calculated as if the operation were</p><pre>SUM(c) OVER(<br>  ORDER BY b ASC <br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>In our example, the table will be split into the partitions below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*HtVDm70kqiAz6RXBN1cdog.png" /></figure><p>and so on.</p><p>The key requirement for supporting streaming execution for this windowing operation is the ability to somehow tell when a specific partition finalizes; as only then we can emit its associated results for window frames that “touch” the partition boundary.</p><h3>Leveraging input data ordering for partitioning</h3><p>Let’s first consider cases where the existing data (input) ordering helps us deal with partitions. In general; we can support streaming execution for a windowing operation involving partitions if the existing data ordering can be exploited to locate partition boundaries. We can formalize this observation as follows:</p><blockquote><em>If the existing data (input) ordering satisfies the ordering associated with the expression(s) in the </em><em>PARTITION BY clause (in either direction for any of its constituent keys), then the windowing operation is streamable. For our example, the input should satisfy either </em><em>a ASC, or </em><em>a DESC, or any lexicographical extension of these orderings.</em></blockquote><p>Interestingly, we have even more flexibilities when we have composite partition keys. For example, consider the following window expression:</p><pre>SUM(c) OVER(<br>  PARTITION BY a, c<br>  ORDER BY b ASC<br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>Here, each distinct (a, c) tuple would induce a partition. For our case, the partitions would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*du1JS9IQBVPu_I0gdRzXEQ.png" /></figure><p>and so on.</p><p>In this example, the existing ordering (a ASC, b ASC) does not match perfectly with the keys of the PARTITION BY clause (a, c). However, they do share the prefix a. Can we still leverage this shared prefix? The answer is yes, because the clause PARTITION BY a, c describes a finer partitioning than the clause PARTITION BY a. Therefore; when we receive a new value of a = a_new after some a = a_last, we can be sure that any partition of the form (a = a_last, c = ...) will no longer receive any new rows since we can no longer receive an a = a_last value due to our input data ordering. Hence, all of the partitions where a = a_last can be finalized/emitted. These observations motivate us to relax our first streamability condition into the following:</p><blockquote><em>One of the </em><em>PARTITION BY expressions should be a leading ordering expression (first expression in some existing data (input) ordering).</em></blockquote><p>The table below shows some examples showing streamable and non-streamable cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*zgvITNvh443845zZlmI2Ow.png" /></figure><p><strong>Remark:</strong> Note that we do not have any constraint on the window frame specification in this case. Unlike the partitionless case, the window frame may end with an UNBOUNDED FOLLOWING here.</p><p><strong>Remark:</strong> As mentioned before, directionality of data ordering doesn’t matter when assessing the PARTITION BY clause for streamability. What we care about is the ability to tell when a partition ends. In other words, it is enough to have the guarantee that when we receive a new value for the PARTITION BY expression, we will never receive any previous expression value again.</p><h3>Leveraging hashing for partitioning</h3><p>Even when the existing data (input) ordering doesn’t help us deal with partitions, we can still support streaming execution in certain cases by leveraging hashing. Specifically, consider the case where:</p><ul><li>None of the PARTITION BY expressions matches any leading ordering expression (the first expression in some existing data (input) ordering).</li><li>Conditions for the case when the query doesn’t contain a PARTITION BY clause hold.</li></ul><p>As an example, consider the window expression below:</p><pre>SUM(c) OVER(<br>  PARTITION BY c<br>  ORDER BY ts ASC<br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>Column c is not a leading ordering column in any existing data (input) ordering, so we cannot be sure when a partition finalizes with our previous methods. What else can we do? Let’s first look at how the above expression splits our example table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*U__ouvV0scKuzldzVNDdrA.png" /></figure><p>and so on.</p><p>Now, observe that the window expression reduces to the following per-partition window expression:</p><pre>SUM(c) OVER(<br>  ORDER BY ts ASC <br>  ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING<br>)</pre><p>Analyzed independently, this per-partition window expression satisfies our streamability conditions. This gives us a way out:</p><blockquote><em>If our conditions for the partition-less case holds for every partition separately; then we can operate on, prune and emit results for each partition concurrently as new data arrives. However, since we will never know when a partitions ends, we will have to keep track of each distinct partition throughout execution. In high cardinality cases, this version may use significant memory, but it is nevertheless pipeline-friendly.</em></blockquote><h3>Streamability summary</h3><p>We are done with our case analysis, so let’s put together everything we have covered so far in one single statement: For a window expression to be streamable, or pipeline-friendly, we require:</p><ul><li>One of the PARTITION BY expressions to be a leading ordering expression (first expression in some existing data (input) ordering), <em>or</em></li><li>The leading ordering requirement to match with an existing leading ordering <strong><em>and</em></strong> the window frame to not end with UNBOUNDED FOLLOWING.</li></ul><p>For the sake of clarity, we also provide a truth table encoding the above statement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0K4tI1-5fRqpMoRyNqy2w.png" /></figure><h3>Handling Multiple Window Expressions</h3><p>When a query contains multiple window expressions, the query is streamable (as a whole) if all the constituent window expressions are individually streamable. As an example, consider the query below:</p><pre>SELECT<br>  SUM(c) OVER(<br>    ORDER BY ts ASC<br>    ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>  ) AS sum_last_ten_ts,<br>  SUM(c) OVER(<br>    ORDER BY a ASC, b ASC<br>    ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>  ) AS sum_last_ten_a_b<br>FROM source</pre><p>Since our input table (source) satisfies the requirements ts ASC and (a ASC, b ASC) simultaneously, both window expressions are streamable — they both correspond to <em>Case 2</em> in the summary table above.</p><p>Next, let’s analyze a more complex example. Consider the query below:</p><pre>SELECT<br>  SUM(c) OVER(<br>    ORDER BY ts ASC<br>    ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>  ) AS sum_last_ten_ts,<br>  SUM(c) OVER(<br>    ORDER BY ts DESC**<br>    ROWS BETWEEN 10 PRECEDING AND CURRENT ROW<br>  ) AS reverse_sum_last_ten_ts<br>FROM source</pre><p>In this query, one of the window expressions has the ordering requirement ts ASC while the other has ts DESC. At first glance, these window expressions seem to have conflicting requirements, suggesting that this query may not be streamable. When we check streamability conditions for these window expressions, the first window expression corresponds to <em>Case 2</em> (streamable), but the second window expression corresponds to <em>Case 0</em> (not streamable).</p><p>However, we can actually salvage this query by leveraging a simple property of window functions; i.e. most window functions are directionally insensitive. In other words, we can calculate their results even if we scan their inputs in the opposite direction (relative to their ordering requirements). In order to obtain the correct result while scanning the input in the opposite direction, we just have to modify/re-write the window frame clause. For our example, the alternate re-writing of the reverse_sum_last_ten_ts expression is:</p><pre>SUM(c) OVER(<br>  ORDER BY ts ASC<br>  ROWS CURRENT ROW AND 10 FOLLOWING<br>) AS alternate_reverse_sum_last_ten_ts</pre><p>Note that the ordering requirement is exactly the opposite of the original ordering requirement. After this re-write, our two window expressions now have compatible requirements amenable to streaming execution, making the whole query streamable.</p><h3>Constructing Equivalent Window Frames for Reverse Expressions</h3><p>The section above lays out the core idea for window expression reversals, but some details were left vague. For example, what exactly does “modifying/re-writing” the window frame clause mean? We explore such details in this section.</p><p>The algorithm for constructing/re-writing equivalent window frames is actually rather simple:</p><ul><li>If the window frame boundary is of the form BETWEEN M PRECEDING AND N FOLLOWING, then we swap PRECEDING and FOLLOWING values, resulting in a window frame boundary of the form BETWEEN N PRECEDING AND M FOLLOWING.</li><li>If one side of the window frame contains CURRENT ROW, then we swap frame boundaries and reverse the other side. For instance, if the window frame boundary is of the form BETWEEN M PRECEDING AND CURRENT ROW , then the re-written window frame is of the form BETWEEN CURRENT ROW AND M FOLLOWING.</li></ul><p>A Rust-like pseudocode implementation of this logic is as follows:</p><pre>start_bound = old_window_frame.start_bound;<br>end_bound = old_window_frame.end_bound;<br>mode = old_window_frame.mode; // RANGE, ROWS, GROUPS<br><br>// Find the &quot;reversed&quot; start bound:<br>if end_bound == WindowFrameBound::Preceding(number)<br>    rev_start_bound = WindowFrameBound::Following(number)<br>else if end_bound == WindowFrameBound::CurrentRow<br>    rev_start_bound = WindowFrameBound::CurrentRow<br>else if end_bounde == WindowFrameBound::Following(number)<br>    rev_start_bound = WindowFrameBound::Preceding(number)<br>else<br>    Not Possible<br><br>// Find the &quot;reversed&quot; end bound:<br>if start_bound == WindowFrameBound::Preceding(number)<br>    rev_end_bound = WindowFrameBound::Following(number)<br>else if start_bound == WindowFrameBound::CurrentRow<br>    rev_end_bound = WindowFrameBound::CurrentRow<br>else if start_bound == WindowFrameBound::Following(number)<br>    rev_end_bound = WindowFrameBound::Preceding(number)<br>else<br>    Not Possible<br><br>// Same mode should be used:<br>reversed_window_frame = WindowFrame{rev_start_bound, rev_end_bound, mode}</pre><p>We can summarize our findings on window frame reversal as follows:</p><blockquote><em>If the ordering requirement of a window expression and the existing data (input) ordering is exactly the opposite, the window expression is still streamable if streamability conditions hold for the alternate (i.e. “reversed”) version of the expression.</em></blockquote><p><strong>Remark:</strong> Certain window functions (such as FIRST_VALUE) are directionally sensitive, but are still amenable to our reversal technique. When dealing with such a “friendly” function, we simply swap the function with its dual. For instance, the following window expression</p><pre>FIRST_VALUE(a) OVER(<br>  ORDER BY ts DESC <br>  ROWS BETWEEN 10 PRECEDING AND 1 FOLLOWING<br>)</pre><p>turns into</p><pre>LAST_VALUE(a) OVER(<br>  ORDER BY ts ASC <br>  ROWS BETWEEN 1 PRECEDING AND 10 FOLLOWING<br>)</pre><p>when applying our reversal technique. However, most window and aggregate functions are directionally insensitive (e.g. SUM, MIN, MAX, AVG), so they remain the same as we reverse window expressions involving them.</p><h3>Stateful Calculations</h3><p>So far, we focused on streamability requirements without considering any memory implications. Our working definition was that an operation is streamable if we can start emitting its results without scanning its entire input. However, this may still require us to use unbounded memory, which is not feasible. As an example, window frames that start with UNBOUNDED PRECEDING <em>may</em> require us to store an unbounded amount of data. Consider the window expression below:</p><pre>SOME_WINDOW_FUNCTION(c) OVER(<br>  ORDER BY ts ASC<br>  ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING<br>)</pre><p>Unless we know that SOME_WINDOW_FUNCTION is amenable to incremental/stateful computation, this window expression may force us to store an ever-growing amount of data as we go through the input. The following table summarizes the rows we need to keep in memory in the worst case as we evaluate this window expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*b3KqS33qcp1WASm4-unvKQ.png" /></figure><p>Fortunately, we can incrementally calculate/update results for most window functions without storing all the associated rows.</p><p>Consider the SUM function: We know that <strong><em>SUM(x,y,z,t)</em></strong> is equal to <strong><em>SUM(x,y,z) + t</em></strong>. In other words, we compute the sum function in an accumulating fashion: Once we compute the sum value for rows 1, 2, …, N; we no longer need to store these rows when processing the rest of our input data — all the information we will ever need will be in the accumulated value.</p><p>As another example, consider the MIN function: We know that <strong><em>MIN(x, y, z, t)</em> </strong>is equal to <strong><em>MIN(MIN(x, y, z), t)</em></strong>. Therefore, once we compute the minimum for rows 1, 2, …, N; we no longer need to store these rows when processing the rest of our input data. Similar algorithms can be constructed for other commonly used window functions.</p><p>However, there are “memory-unfriendly” window functions as well. Consider the ARRAY_AGG function, which constructs an array object from its input data. Even though we can emit its results without scanning the entire input, we will need to keep track of all its associated rows as we execute the query. Therefore, if a window expression involves a frame starting with UNBOUNDED PRECEDING, we will face an ever-growing (and unavoidable!) memory usage.</p><h3>References and Footnotes</h3><p>[1] <a href="https://www.postgresql.org/docs/current/queries-table-expressions.html#QUERIES-WINDOW">PostgreSQL documentation</a>: Window function processing</p><p>[2] <a href="https://en.wikipedia.org/wiki/Window_function_(SQL)">Wikipedia article</a> on SQL window functions.</p><p>[3] When there are multiple equivalent input orderings, it is enough for this statement to be true for one such ordering.</p><p>[4] <a href="https://www.oreilly.com/library/view/streaming-systems/9781491983867/">Streaming systems</a> by Tyler Akidau, Slava Chernyak and Reuven Lax. This is an excellent book to learn what is “under the hood” in stream processing systems. You will not just learn how to use a specific stream processing library or framework, but digest general stream processing concepts and how one can implement such libraries or frameworks. In this sense, this book will always be relevant.</p><p>[5] <a href="https://www.vldb.org/pvldb/vol8/p1058-leis.pdf">Efficient Processing of Window Functions in Analytical SQL Queries</a> by Viktor Leis, Alfons Kemper, Kan Kundhikanjana and Thomas Neumann is great read for those who want to learn more about implementations of window functions.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/akurmustafa/">Mustafa Akur</a>, Software Engineer @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93068d3a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Sliding Window Hash Join Algorithm: Efficiently Joining Infinite Streams with Order…]]></title>
            <link>https://synnada.medium.com/the-sliding-window-hash-join-algorithm-efficiently-joining-infinite-streams-with-order-preservation-379d115c8499?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/379d115c8499</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 16:02:03 GMT</pubDate>
            <atom:updated>2023-08-17T07:40:56.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BNVinBl6XG7sbgY54WJnfQ.png" /></figure><h3>Sliding Window Hash Join Algorithm: Efficiently Joining Infinite Streams with Order Preservation</h3><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/sliding-window-hash-join-swhj"><strong>Synnada</strong></a> on August 1, 2023 and is part of our ongoing series on streaming SQL engines and advanced join algorithms. In previous posts, we discussed techniques like <a href="https://www.synnada.ai/blog/probabilistic-data-structures-in-streaming-count-min-sketch"><strong>Probabilistic Data Structures in Streaming: Count-Min Sketch</strong></a>, <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>General-purpose Stream Joins via Pruning Symmetric Hash Joins</strong></a> and <a href="https://medium.com/@synnada/running-windowing-queries-in-stream-processing-93068d3a5"><strong>Running Windowing Queries in Stream Processing</strong></a> that serve as building blocks. The concepts discussed in this series are implemented in Apache Arrow/DataFusion, which has a bunch of other cool features we haven’t talked about yet.</blockquote><p>In a previous post, we discussed <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>the Symmetric Hash Join (SHJ) algorithm</strong></a> and its implementation in Apache <a href="https://arrow.apache.org/datafusion/"><strong>Arrow/Datafusion</strong></a>, an advanced feature aimed at enhancing stream processing features of the Datafusion query engine. As part of that work, we introduced the concept of build-side pruning, a technique that boosts performance by removing irrelevant rows from the memory early in the join operation. As we continue to strengthen the capabilities of our query processing engine in our effort to implement the <a href="https://milinda.pathirage.org/kappa-architecture.com/"><strong>Kappa architecture</strong></a>, we now turn our focus to another innovative incremental processing algorithm — the <strong>Sliding Window Hash Join (SWHJ).</strong></p><p>The SWHJ is specifically designed for joining two possibly infinite streams while preserving the order of one of the input streams. The ordinary hash join algorithm has order-preserving properties but it is stream-unfriendly; while the SHJ algorithm is stream-friendly but fails to preserve input ordering. The SWHJ algorithm offers a “best of both worlds” solution whenever a sliding window constraint is applicable in one’s use case. Basically, SWHJ improves on the ordinary hash join algorithm by incrementally building/maintaining its hash table instead of materializing/scanning its entire input, whenever possible.</p><h3>Background</h3><h4>Context: Query processing and streams</h4><p>Consider the data flow between various stages or operators in a pipelined query execution engine; where each stage/operator performs a specific operation, refining the data as it travels through the system.</p><p>In an ideal situation, the query planning step identifies the optimal execution plan for the given query and the dataset. However, in stream processing, not all operators support continuous data flows. Some might disrupt or “break” the pipeline, making the query inexecutable.</p><p>These “pipeline-breaking” operators may require to “see” the entire input, or utilize excessively long lookaheads, or simply store impractically large intermediate results. All these behaviors slow down the entire process, or worse, halt the pipeline entirely. The goal, then, is to use only stream-friendly operators that maintain a smooth and uninterrupted flow of data while minimizing processing blocks or unnecessary storage.</p><p>While some operations, like sorting, are inherently incompatible with this goal, many scenarios permit solutions using only stream-friendly operators.</p><h4>Context: Hash Join order preserving characteristics</h4><p>A hash join operation consists of two main phases, the build phase and the probe phase:</p><ul><li>In the build phase; we construct a hash table using one of the input tables, commonly referred to as the <em>build side</em>. This hash table is built based on the join keys of the build side.</li><li>In the probe phase; we scan the other input table, commonly referred to as the <em>probe side</em>. For each probe side row, we consult the hash table created in the build phase to find any matching rows from the build side.</li></ul><p>Order-preserving characteristics of the hash join algorithm depends on how we carry out the probe phase: The order in which we scan and process probe side rows is typically the order in which they appear in the original table, which directly reflects to the result of the hash join.</p><figure><img alt="Figure 1: Build and probe sides of the Hash Join algorithm." src="https://cdn-images-1.medium.com/max/851/1*lSU6a3yxrvoML0dHrbqYoQ.png" /><figcaption>Figure 1: Build and probe sides of the Hash Join algorithm.</figcaption></figure><p>Furthermore, if our hash table is an insertion-order-preserving hash table, each probe side row’s matching build side rows will follow their original ordering from the build side, implying a lexicographical ordering in our final join results.</p><p>In agreement with the above analysis, Datafusion maintains the right (i.e. probe) side order for <strong>Inner</strong>, <strong>RightSemi</strong> and <strong>RightAnti</strong> joins. Moreover, Datafusion’s hash tables preserve insertion ordering. Therefore, if the left side is sorted by <strong>a</strong> (in ascending order) and the right side is sorted by <strong>b</strong> (in ascending order), then inner join results will be sorted by <strong>b, a</strong> (in ascending order).</p><h3>Sliding Window Hash Join: A brief explanation</h3><p>As its name suggests, SWHJ is an adaptation/generalization of the ordinary hash join algorithm that can accommodate infinite streams when dealing with sliding windows. Unlike <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>the SHJ algorithm</strong></a> that utilizes two hash tables and treats its two inputs on an equal footing, the SWHJ algorithm fixes one side of the join as the build side (left) and the other side as the probe side (right) — just like the ordinary hash join algorithm. However, unlike the ordinary hash join, SWHJ exploits the sliding window constraint to incrementally build its hash table. This way, it is able to maintain the order of the right input stream while efficiently processing incoming rows from both streams without consuming the entire left stream.</p><p>To see why one does not need to materialize the whole build side when executing a sliding window join, let’s examine a simple example query:</p><pre>SELECT t1.*<br>FROM t1<br>JOIN t2<br>ON t1.id = t2.id AND<br>   t1.ts &gt;= t2.ts AND<br>   t1.ts &lt; t2.ts + 1 DAY</pre><p>where both tables are ordered with respect to the <strong>ts</strong> column. Now, the join rules are:</p><ol><li>The <strong>id</strong> in both tables must be the same.</li><li>The timestamp (<strong>ts</strong>) in <strong>t1</strong> is the same or later than the timestamp in <strong>t2</strong>.</li><li>The timestamp in <strong>t1</strong> is less than the timestamp in <strong>t2</strong> plus one day.</li></ol><p>So, it’s like saying: “Show me everything from table <strong>t1</strong> where the same <strong>id</strong> exists in table <strong>t2</strong> and the time in <strong>t1</strong> is between the time in <strong>t2</strong> and that time plus one day.&quot;</p><p>Since <strong>t1</strong> and <strong>t2</strong> are both sorted according to <strong>ts</strong> and we have the sliding window constraint, it is not necessary to materialize every row on the build side for any particular probe row/batch; only considering a days worth of data is enough for producing all viable matches. This presents a significant advantage for stream processing because it limits the required build-side information for a specific probe batch.</p><figure><img alt="Figure 2: Viable matches for a given probe side batch." src="https://cdn-images-1.medium.com/max/781/1*U-FHNLG5Zom1ftGnc-Iu_w.png" /><figcaption>Figure 2: Viable matches for a given probe side batch.</figcaption></figure><p>The essence of the SWHJ algorithm lies in the creation of a smaller, incrementally maintainable hash table that only contains data falling in this sliding window from the build side. This window’s boundaries are calculated using interval arithmetic, a concept we’ve previously discussed <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins#:~:text=refine%20variable%20bounds.-,Interval%20Arithmetic,-Interval%20arithmetic%20is">in a blog post</a>.</p><p>Each specific row, or batch of rows on the probe side, can only match with a finite-size sliding window on the build side; and we use this information to avoid reading the entire build side. This method becomes significantly advantageous when dealing with infinite streams, allowing us to manage relevant windows within these streams. Moreover, the assumption that both sides could be infinite doesn’t hinder the execution of the algorithm anymore. Instead, we are able to designate a boundary for the hashable portion of the stream, all thanks to the join filter expression. In this process, we’re essentially dealing with a bounded build side and harnessing the order-preserving attributes of the ordinary hash join algorithm.</p><h3>Use cases: When is it appropriate?</h3><h4>1. Easy sliding windows via join filters</h4><pre>SELECT t1.*<br>FROM t1<br>JOIN t2<br>ON t1.id = t2.id AND<br>   t1.ts &gt;= t2.ts AND<br>   t1.ts &lt; t2.ts + 1 DAY</pre><p>Join filters defining time-based sliding windows are the most common and natural use cases for the SWHJ algorithm. Above, we reproduce the simple sliding window query from our previous example. Join conditions <strong>t1.ts &gt;= t2.ts</strong> and <strong>t1.ts &lt; t2.ts + 1 DAY</strong> create a sliding time window of one day. For each row in <strong>t1</strong>, the query is looking for matching rows in <strong>t2</strong> that have the same <strong>id</strong> and a timestamp within the preceding day.</p><pre>SELECT t1.*<br>FROM t2<br>JOIN t1<br>ON t1.id = t2.id AND<br>   t1.sn &gt;= t2.sn AND<br>   t1.sn &lt; t2.sn + 10</pre><p>A slightly different variant of this query may use a count-based sliding window: Assuming that the column <strong>sn</strong> represents some sort of a sequence number for events, join conditions <strong>t1.sn &gt;= t2.sn</strong> and <strong>t1.sn &lt; t2.sn + 10</strong> describe a sliding window of ten events. For each row in <strong>t1</strong>, it&#39;s looking for matching rows in <strong>t2</strong> that have the same <strong>id</strong> and a sequence number within the preceding ten numbers.</p><p>Note that we have not used any special function(s) or syntax to describe these sliding windows. Simply by using the comparison operators (<strong>&gt;=</strong> and <strong>&lt;</strong>) within the join condition, we defined our sliding window boundaries, ensuring that only rows within these boundaries are considered for matching and joining. A naive query engine without the SWHJ algorithm would have to consider every row in both tables, which would be inefficient for large datasets, and worsely, inexecutable for continuous data streams.</p><h4>2. Performing non-causal/symmetric stream joins</h4><p>Consider the following tables where the attribute <strong>sn</strong> represents a sequence number for events:</p><p>Table <strong>t1</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*I5mYI763IKbAt9_qWM1ARg.png" /></figure><p>Table <strong>t2</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*C7_Cry6kc1fTw5x94-bynA.png" /></figure><p>Let’s say we want to match all events whose sequence numbers are “close”. Note that this relationship is symmetric, so it requires a non-causal join filter as in the query below:</p><pre>SELECT t1.*<br>FROM t1<br>JOIN t2<br>ON t1.id = t2.id AND<br>   t1.sn &gt;= t2.sn AND<br>   t1.sn &lt; t2.sn + 10</pre><p>This query will give us rows from <strong>t1</strong> (<strong>t2</strong>) that have the same <strong>id</strong> as in <strong>t2</strong> (<strong>t1</strong>), and an <strong>sn</strong> that is within the range of <strong>t2.sn - 10</strong> (<strong>t1.sn - 10</strong>) and <strong>t2.sn + 10</strong> (<strong>t1.sn + 10</strong>).</p><p>The following table shows the outcome when the provided SQL query is executed on the given tables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*66HnziObSZnp4ofrsUFMaA.png" /></figure><p>For the row <strong>[2, 205]</strong> from table <strong>t2</strong>, the possible matches from table <strong>t1</strong> (the build side) are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*W-lSo2_0D3mLPQbFmWrQXg.png" /></figure><p>In a real use case, one often applies some aggregation logic to these matches, but we chose to leave that out so that we can show you the “insides” of how these joins work under the hood.</p><h3>Digging deeper: Algorithmic details</h3><p>Let’s start off by declaring our goals with the SWHJ algorithm. We aim to:</p><ol><li>Support all types of joins and achieve order preservation for all join types that are amenable.</li><li>Keep buffers for both sides finite.</li><li>Preserve the right side order, whenever possible, by exclusively probing the right side.</li></ol><p>By focusing on these objectives, we can develop an efficient algorithm for joining infinite streams while maintaining the order of the right input stream and accommodating various join types.</p><h4>The Algorithm</h4><p>We will discuss the SWHJ algorithm at two levels: First, we will give a high-level description of the SWHJ algorithm. Next, we will present pseudocode laying out the algorithm as a finite state machine.</p><p>The algorithm starts off by initializing the left (build) side buffer and a data structure to keep track of the visited rows from the left side. Throughout its operation, the algorithm will always maintain an interval that stores left side buffer boundaries. Recall that we will continuously processes any incoming data from both left and right streams — we will not consume any one side exclusively until exhaustion.</p><ul><li>Every time the algorithm fetches a <strong>RecordBatch</strong> from the right stream, it computes the interval storing the range of this batch. Then, it uses this interval to shrink the build side interval using constraint propagation. This shrunk range will determine the new build-side sliding window bounds.</li></ul><figure><img alt="Figure 3: Buffers for a query with join conditions l.d = r.b and r.a &gt; l.c — 15 and r.a &lt; l.c + 2." src="https://cdn-images-1.medium.com/max/1024/1*G5KUO5l-NGnIiMFGKOrhiw.png" /><figcaption>Figure 3: Buffers for a query with join conditions <strong>l.d = r.b</strong> and <strong>r.a &gt; l.c — 15</strong> and <strong>r.a &lt; l.c + 2</strong>.</figcaption></figure><ul><li>If the latest element in the left buffer isn’t enough to cover the whole sliding window, the algorithm keeps fetching more data from the build side stream. Once there’s enough data; it uses the build side buffer to perform a hash join between the right record batch and the left buffer. If the join type is <strong>Inner</strong>, <strong>Right</strong>, <strong>RightSemi</strong> or <strong>RightAnti</strong>, the algorithm can produce order preserving results since the right side is the probe side.</li><li>For <strong>Left</strong>, <strong>LeftSemi</strong> ,<strong>LeftAnti</strong> and <strong>Full</strong> join types, the algorithm records the visited rows from the left side.</li><li>With lower and upper bounds of the sliding window in hand, the algorithm prunes the build side buffer using the lower bound. If the join type is <strong>Left</strong>, <strong>Full</strong>, <strong>LeftSemi</strong> or <strong>LeftAnti</strong>, it also produces unmatched results from pruned left rows.</li></ul><figure><img alt="Figure 4: Matching and pruning for a query with join conditions l.d = r.b and r.a &gt; l.c — 15 and r.a &lt; l.c + 2." src="https://cdn-images-1.medium.com/max/1024/1*vYYOilCd0KV0RZOUWARVOw.png" /><figcaption>Figure 4: Matching and pruning for a query with join conditions <strong>l.d = r.b</strong> and <strong>r.a &gt; l.c — 15</strong> and <strong>r.a &lt; l.c + 2</strong>.</figcaption></figure><ul><li>When there is no more data in the right stream, the algorithm continues to pull left stream and calculates any unmatched results if the join type is <strong>Left</strong>, <strong>LeftSemi,</strong> <strong>LefttAnti</strong> or <strong>Full</strong>. Otherwise, it just finishes the execution.</li><li>If there is no more data in the left stream, the algorithm continues the calculation by reading the right stream one by one as usual, but it won’t poll the left stream anymore. The remaining build side buffer is used to continue the execution.</li></ul><p>The above list highlights the most important points, but we feel a state machine approach is more helpful for anyone who wants to implement the SWHJ for themselves:</p><pre>Repeat indefinitely:<br>  Check the state of the process:<br>      Case &quot;PullProbe&quot;:<br>          Fetch next item from right_stream<br>          If an item is received:<br>              Update metrics<br>              Check if batch is suitable for further processing<br>              If not suitable, break the loop<br>          If no item received, break the loop<br>          If there is an error, return error status<br>          If no batches were collected, change state to &quot;ProbeExhausted&quot; and continue<br>          Process collected batches and calculate necessary parameters for the next state &quot;PullBuild&quot;<br>			<br>      Case &quot;PullBuild&quot;:<br>          Fetch next item from left_stream<br>          If an item is received, process the item and update metrics and check conditions<br>          If no item received, update the state to &quot;BuildExhausted&quot;<br>          If there is an error, return error status<br><br>      Case &quot;BuildExhausted&quot;:<br>          Update state to &quot;Join&quot;<br>      <br>      Case &quot;ProbeExhausted&quot;:<br>          Fetch next item from left_stream<br>          If an item is received, process the item, update metrics and return result if exists<br>          If no item received, update state to &quot;BothExhausted&quot; with final result as false<br>          If there is an error, return error status<br>      <br>      Case &quot;Join&quot;:<br>          Perform join operation and calculate necessary parameters<br>          Prune internal state if possible<br>          Combine results and update state to &quot;PullProbe&quot;<br>          Update metrics and memory usage<br>          If result exists, return the result<br>      <br>      Case &quot;BothExhausted&quot; with final result true:<br>          Return &quot;None&quot; indicating we are done<br>      <br>      Case &quot;BothExhausted&quot; with final result false:<br>          Create result from the current state<br>          Update state to &quot;BothExhausted&quot; with final result as true<br>          If result exists, update output metrics and return the result</pre><h3>Roadmap</h3><p>There are various possible enhancements that can make our query engine even more performant and stream friendly. Some enhancements we plan to work on in the near future include:</p><ul><li>Improving the buffered hash table implementation for higher performance,</li><li>Using this plan in complex, order-preserving stream processing pipelines,</li><li>Developing even more pipeline friendly join operators.</li></ul><h3>Inspirations</h3><ol><li><a href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43864.pdf"><strong>The Dataflow Model: Balancing Correctness, Latency, and Cost in Stream Processing</strong></a> — <a href="https://twitter.com/takidau?lang=en">Tyler Akidau</a>, <a href="https://www.linkedin.com/in/alexander-balikov-0b776886/">Alex Balikov</a>, et al. — Exploring the practical approach to processing massive-scale, unbounded data with low-latency and cost-effectiveness.</li><li><a href="https://arxiv.org/abs/2208.09827"><strong>A Survey on Transactional Stream Processing</strong></a> — <a href="https://shuhaozhangtony.github.io/">Shuhao Zhang</a>, <a href="https://www.user.tu-berlin.de/juan.soto/">Juan Soto</a>, <a href="https://www.tu.berlin/en/dima/about-us/prof-dr-volker-markl">Volker Markl</a> — Transactional stream processing (TSP) strives to create a cohesive model that merges the advantages of both transactional and stream-oriented guarantees. This survey provides insights into diverse TSP requirements and methodologies and aims to inspire the design of groundbreaking TSP systems.</li><li><a href="https://www.amazon.com/Designing-Data-Intensive-Applications-Reliable-Maintainable/dp/1449373321"><strong>Designing Data-Intensive Applications: Principles for Reliable, Scalable, and Maintainable Systems</strong></a> — <a href="https://twitter.com/martinkl?lang=en">Martin Kleppmann</a> — Unveiling the big ideas behind building data-intensive applications, including stream processing and distributed systems.</li></ol><h3>About Synnada</h3><p><a href="https://www.notion.so/Project-Sanity-c574da5f065e4c769c7462dd18118d32?pvs=21">Synnada</a> helps you build interactive, collaborative, intelligent, real-time data applications for your mission-critical systems, within minutes and with ease — powered by SQL and online machine learning.</p><p>We have <strong>a simple goal: Unify data, make it real-time and accessible for AI-driven applications.</strong> We strive to empower data artisans of the future by providing them with elemental blocks and infrastructure components required to create, maintain and optimize intelligent, real-time, mission-critical data systems.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/meteyyildirim/?originalSubdomain=tr">Metehan Yıldırım</a>, Software Engineer @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=379d115c8499" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Probabilistic Data Structures in Streaming: Count-Min Sketch]]></title>
            <link>https://synnada.medium.com/probabilistic-data-structures-in-streaming-count-min-sketch-e65d728d3264?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e65d728d3264</guid>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 16:46:44 GMT</pubDate>
            <atom:updated>2023-08-17T07:42:22.222Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i59Q01YoaKHTiEq5PRNCBA.png" /></figure><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/probabilistic-data-structures-in-streaming-count-min-sketch"><strong>Synnada</strong></a> on July 13, 2023 and is part of our ongoing series on streaming SQL engines and advanced join algorithms. In previous posts, we discussed techniques like <a href="http://www.synnada.ai/blog/sliding-window-hash-join-swhj"><strong>The Sliding Window Hash Join Algorithm: Efficiently Joining Infinite Streams with Order Preservation</strong></a> and <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>General-purpose Stream Joins via Pruning Symmetric Hash Joins</strong></a> and <a href="https://medium.com/@synnada/running-windowing-queries-in-stream-processing-93068d3a5"><strong>Running Windowing Queries in Stream Processing</strong></a> that serve as building blocks. The concepts discussed in this series are implemented in Apache Arrow/DataFusion, which has a bunch of other cool features we haven’t talked about yet.</blockquote><p>The Count-Min Sketch (CMS) is a probabilistic data structure that can be used to estimate the frequency of items in a stream of data. It is particularly useful when the size of the data stream is too large to store in memory, or when we want to perform frequent updates to the data stream in real-time.</p><p>To understand how the CMS works, it’s helpful to first understand some basic concepts:</p><ul><li><strong>Hash functions</strong> are functions that take an input (such as a string or a number) and produce a fixed-size output (called a “hash value”) in a way that is difficult to predict or reverse. Hash functions are often used to store and retrieve data efficiently, as they allow us to map data items to indices in an array without having to store the data itself.</li><li><strong>Probabilistic data structures</strong> are data structures that use randomness to achieve their goals with a certain probability. This means that the results of probabilistic data structures are not always accurate, but the probability of error can be controlled by the user.</li></ul><p>The basic idea behind the CMS is to use hash functions to map items in the stream to a fixed-size array, and then use this array to store an estimate of the frequency of each item. The CMS maintains a two-dimensional array of counters, where each row corresponds to a hash function and each column corresponds to a hash value. When an item is encountered in the stream, it is hashed using each of the hash functions and the corresponding counters are incremented.</p><p>Let’s figure it out with a simple example. First, we’ll initialize the table with all zeros:</p><pre>+---+---+---+---+---+---+---+---+<br>| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |<br>+---+---+---+---+---+---+---+---+<br>| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |<br>+---+---+---+---+---+---+---+---+<br>| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |<br>+---+---+---+---+---+---+---+---+</pre><p>Now, let’s say we want to process the following stream of items: <strong>[&quot;apple, &quot;banana&quot;, &quot;cherry&quot;]</strong></p><p>To update the table with this data, we’ll need to increment the count at the positions in the table that are mapped to by each of our hash functions for each item in the stream.</p><p>For example, the first item in the stream is <strong>&quot;apple&quot;</strong>. The positions in the table that are mapped to by each of our hash functions for this item are:</p><ul><li>hash1(“apple”): 3</li><li>hash2(“apple”): 1</li><li>hash3(“apple”): 4</li></ul><p>So, we’ll increment the count at these positions in the table:</p><pre>+---+---+---+---+---+---+---+---+<br>|  0|  0|  0|  <strong>1</strong>|  0|  0|  0|  0|<br>+---+---+---+---+---+---+---+---+<br>|  0|  <strong>1</strong>|  0|  0|  0|  0|  0|  0|<br>+---+---+---+---+---+---+---+---+<br>|  0|  0|  0|  0|  <strong>1</strong>|  0|  0|  0|<br>+---+---+---+---+---+---+---+---+</pre><p>Now, let’s add the second item in the stream, <strong>&quot;banana&quot;</strong>. The positions in the table that are mapped to by each of our hash functions for this item are:</p><ul><li>hash1(“banana”): 1</li><li>hash2(“banana”): 7</li><li>hash3(“banana”): 3</li></ul><p>So, we’ll increment the count at these positions in the table:</p><pre>+---+----+---+----+---+---+---+----+<br>|  0|   <strong>1</strong>|  0|   1|  0|  0|  0|   0|<br>+---+----+---+----+---+---+---+----+<br>|  0|   1|  0|   0|  0|  0|  0|   <strong>1</strong>|<br>+---+----+---+----+---+---+---+----+<br>|  0|   0|  0|   <strong>1</strong>|  1|  0|  0|   0|<br>+---+----+---+----+---+---+---+----+</pre><p>And, <strong>&quot;cherry&quot;</strong>. Suppose, we have a hash collision with apple.</p><ul><li>hash1(“cherry”): 0</li><li>hash2(“cherry”): 1</li><li>hash3(“cherry”): 6</li></ul><p>The final table will look like this:</p><pre>+---+----+---+----+---+---+---+----+<br>|  <strong>1</strong>|   0|  0|   1|  0|  0|  0|   0|<br>+---+----+---+----+---+---+---+----+<br>|  0|   <strong>2</strong>|  0|   0|  0|  0|  0|   1|<br>+---+----+---+----+---+---+---+----+<br>|  0|   0|  0|   1|  1|  0|  <strong>1</strong>|   0|<br>+---+----+---+----+---+---+---+----+</pre><p>Now, let’s say we want to estimate the frequency of the item <strong>&quot;apple&quot;</strong> in the stream. To do this, we&#39;ll look at the positions in the table that are mapped to by each of our hash functions for this item, and take the minimum count at these positions.</p><p>The positions in the table that are mapped to by each of our hash functions for “apple” are:</p><ul><li>hash1(“apple”): 3</li><li>hash2(“apple”): 1</li><li>hash3(“apple”): 4</li></ul><p>And we get [1, 2, 1] from each row. To estimate the frequency of an item, we simply take the minimum value among the counters corresponding to that item across all the rows. This is because the hash functions are designed to evenly distribute items across the array, so the minimum count is likely to be the most accurate estimate of the true frequency.</p><h3>Rust Implementation</h3><h3>Defining the data structure</h3><pre>use rand::Rng;<br>use std::cmp::max;<br>use std::hash::{BuildHasher, Hash, Hasher};<br>use twox_hash::xxh3::Hash64;<br><br>struct CountMinSketch {<br>    counts: Vec&lt;Vec&lt;u64&gt;&gt;,<br>}</pre><p>The CMS is implemented as a two-dimensional array of unsigned 64-bit integers, called <strong>counts</strong>. The dimensions of this array are determined by two parameters: <strong>width</strong> and <strong>depth</strong>.</p><p>The values of <strong>width</strong> and <strong>depth</strong> are chosen to ensure that the <em>error rate</em> of the sketch is within a certain threshold. The error rate of the sketch is defined as the maximum difference between the true frequency of an item and its estimated frequency in the sketch.</p><h3>Choosing parameter values</h3><p>To determine the values of <strong>width</strong> and <strong>depth</strong> that will result in a given error rate, we can use the following formula:</p><pre>width = ceil(e / ε)<br>depth = ceil(ln(1 − δ) / ln(1 / 2))</pre><p>where <em>e</em> is the base of the natural logarithm (approximately 2.718), <strong>ε</strong> is the desired error rate, and <strong>δ</strong> is the desired probability of failure.</p><p>The <strong>width</strong> value is chosen such that the error rate exceeds <strong>ε</strong> with a probability of at most <strong>δ</strong>. Recall that the CMS is a probabilistic data structure, so there is a small chance that the error rate will be higher than the desired value. The probability of failure is typically set to a very small value, such as 10⁻⁹ or 10⁻¹⁰, to ensure that the error rate is very unlikely to exceed the desired value.</p><p>The <strong>depth</strong> value is chosen such that the probability of failure is at most <strong>δ</strong>. This is because the CMS uses multiple hash functions to map items to the array of counters, and the more hash functions that are used, the lower the probability of failure.</p><p><em>Note that there is some ambiguity on how to calculate the these values. Check</em> <a href="https://cs.stackexchange.com/questions/44803/what-is-the-correct-way-to-determine-the-width-and-depth-of-a-count-min-sketch">this post</a> for an in-depth discussion.</p><p>Thus, we can add the utility methods</p><pre>impl&lt;T: Hash&gt; CountMinSketch&lt;T&gt; {<br>  // ...<br>  fn determine_width(tolerance: f64) -&gt; usize {<br>    let width = (std::f64::consts::E / tolerance).round() as usize;<br>    max(2, width).checked_next_power_of_two().unwrap_or(usize::MAX)<br>  }<br><br>  fn determine_depth(probability: f64) -&gt; usize {<br>    let ratio = (1.0 - probability).ln() / 0.5_f64.ln()<br>    max(1, ratio.floor() as usize)<br>  }<br>}</pre><p>and use them to define the <strong>new</strong> method as</p><pre>impl&lt;T: Hash&gt; CountMinSketch&lt;T&gt; {<br>    fn new(probability: f64, tolerance: f64) -&gt; Self {<br>        let width = Self::determine_width(tolerance);<br>        let depth = Self::determine_depth(probability);<br>        Self {<br>            counts: vec![vec![0; width]; depth],<br>        }<br>    }<br>}</pre><h3>Inserting a new element</h3><pre>impl&lt;T: Hash&gt; CountMinSketch&lt;T&gt; {<br>    // ...<br>    fn update&lt;T: Sized + Hash&gt;(&amp;mut self, item: T, count: u64) {<br>        for (seed, row) in self.counts.iter_mut().enumerate() {<br>          let mut hash_function = Hash64::with_seed(seed as u64);<br>          let index = hash_once(&amp;mut hash_function, &amp;item) as usize % row.len();<br>          row[index] += count;<br>        }<br>    }<br>}</pre><p>Every time a new <strong>item</strong> (of duplicity <strong>count</strong>) is arrives from the data stream, we update the CMS to reflect this event. To do this, we first use our <strong>hash functions</strong> to map the item to unique hash values. Then, we use these hash values to update the CMS as follows:</p><ul><li>For each row in the <strong>counts</strong> array, we use the corresponding hash value to determine the index of the element in the row we want to update.</li><li>We then increment the value at this index by the count of the item.</li></ul><p>Here, we use the <a href="http://cyan4973.github.io/xxHash/"><strong>xxHash</strong></a> algorithm in the <strong>hash_once</strong> function to produce hash values for the items being added to the CMS. The algorithm provides:</p><ol><li><strong>High speed</strong>: The <em>xxHash</em> algorithm is known for being very fast and efficient, making it a good choice for use in streaming applications where performance is important.</li><li><strong>Reasonable collision resistance</strong>: The <em>xxHash</em> algorithm doesn’t just produce hash values with a low probability of collision; it is also computationally somewhat difficult to find two inputs generating the same output. This property doesn’t matter for our use case (it is important in security use cases for cryptographic hash functions, which <strong>xxHash</strong> is not), but it increases our confidence that two distinct items are unlikely to get the same hash value. This is important for the CMS, as collisions can lead to incorrect frequency estimates.</li><li><strong>Quality of estimates</strong>: The accuracy of the estimates produced by the CMS depends, in part, on the quality of the hash function being used. The <em>xxHash</em> algorithm is known to produce high-quality hash values (in a distributional sense), which should benefit the estimation accuracy of the CMS.</li></ol><p>Specifically, we used the <strong>xxh3</strong> flavor of <strong>xxHash</strong> here. The <strong>xxh3</strong> algorithm improves on the vanilla <em>xxHash</em> algorithm by leveraging various low-level optimizations while producing the final hash value. It is designed to be faster and produces higher-quality hash values than the original algorithm, particularly for larger input data.</p><p>Here are a few other hash functions that you might consider using in your CMS implementation, along with some pros and cons of each:</p><ol><li><strong>MurmurHash</strong>: <em>MurmurHash</em> is a reasonably fast, non-cryptographic hash function that is widely used in data structures such as hash tables and bloom filters. It is known for being fast and producing reasonable-quality hash values, making it a good choice for use in the CMS. However, its mixing quality is not as high as some other hash functions, so you may see a higher rate of collisions with <em>MurmurHash</em> compared to other options.</li><li><strong>FNV (Fowler-Noll-Vo) hash</strong>: The <em>FNV</em> hash is another non-cryptographic hash function that is sometimes used in data structures. It is known for its simplicity and reasonable mixing properties, but it may not be as fast as some other hash functions.</li></ol><p><a href="https://github.com/Cyan4973/xxHash#benchmarks">The benchmark section of the xxHash source repository</a> is a good source for many other candidates.</p><p>Ultimately, the choice of which hash function to use in the implementation will depend on the specific needs and constraints. Factors to consider might include the speed of the hash function, the collision resistance of the hash values it produces, and the quality of the hash values.</p><h3>Estimating the counts</h3><pre>impl&lt;T: Hash&gt; CountMinSketch&lt;T&gt; {<br>    // ...<br>    fn estimate&lt;T: Sized + Hash + std::fmt::Debug&gt;(&amp;mut self, item: T) -&gt; u64 {<br>        self.counts<br>            .iter()<br>            .enumerate()<br>            .map(|(seed, row)| {<br>                let mut hash_function = Hash64::with_seed(seed as u64);<br>                row[hash_once(&amp;mut hash_function, &amp;item) as usize % row.len()]<br>            })<br>            .min()<br>            .unwrap_or(0)<br>    }<br>}</pre><p>The <strong>estimate</strong> method takes a reference to an item of type <strong>T</strong> and returns an estimate of its frequency in the stream of data. To do this, it iterates over the rows of the <strong>counts</strong> vector, using the <strong>iter</strong> method to get an iterator over the rows.</p><p>For each row, it applies the corresponding hash function to the item to get the index of the column in the row that corresponds to the item. It then retrieves the value at this index and adds it to the stream of values produced by the iterator using the <strong>map</strong> method.</p><p>Finally, it takes the minimum value from this stream of values using the <strong>min</strong> method, and returns it as the estimate of the frequency of the item. If the stream of values is empty (i.e., if the <strong>counts</strong> vector is empty), it returns 0 as the estimate.</p><h3>Conclusion</h3><p>In this article, we have introduced the count-min sketch, a data structure that allows you to estimate the frequency of items in a stream. The count-min sketch is a probabilistic data structure that uses multiple hash functions and a small array of counters to estimate the frequencies of items with a certain error rate.</p><p>We have discussed how to choose the values of <strong>width</strong> and <strong>depth</strong> in the count-min sketch to achieve a desired error rate, and how to select good hash functions to improve the accuracy of the sketch. We have also provided an implementation of the count-min sketch in Rust and discussed how to test it.</p><p>The count-min sketch is a useful tool for processing large streams of data and estimating the frequencies of items. It has many applications, including counting the number of unique visitors to a website, tracking the popularity of items in a recommendation system, and detecting anomalies in network traffic.</p><p>I hope you have found this article helpful and that you have a better understanding of the count-min sketch and how it works. Thank you for reading!</p><p><strong><em>You can see source code from </em></strong><a href="https://github.com/metegenez/probabilitic-data-structures"><strong><em>here</em></strong></a><strong><em>.</em></strong></p><h3>References</h3><ul><li><a href="http://www.mmds.org/">Mining of Massive Datasets</a> by Jure Leskovec, Anand Rajaraman, and Jeff Ullman is a popular textbook that covers the CMS and other algorithms for processing large datasets. It provides a detailed explanation of the error rate of the count-min sketch and how it is related to the values of <strong>width</strong> and <strong>depth</strong>.</li><li><a href="http://dimacs.rutgers.edu/~graham/pubs/papers/cm-full.pdf">The Count-Min Sketch and its Applications</a> by Graham Cormode and S. Muthukrishnan is a research paper that presents the CMS and analyzes its performance. It provides a more detailed analysis of the error rate of the CMS and how it is affected by the values of <strong>width</strong> and <strong>depth</strong>.</li><li>The Wikipedia page <a href="https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch">Count-Min Sketch</a> provides an overview of the CMS and its properties. It includes a section on the error rate and how it is related to the values of <strong>width</strong> and <strong>depth</strong>.</li><li><a href="https://github.com/Cyan4973/xxHash">The xxHash GitHub repository</a> contains the source code of the xxHash algorithm and is a good resource for understanding how it works.</li><li><a href="https://github.com/aappleby/smhasher/wiki">A benchmarking study of hash functions</a>: This study compares the performance of several different hash functions, including xxHash, MurmurHash, FNV, and others. It is a useful resource for understanding the relative performance of these hash functions.</li></ul><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/meteyyildirim/?originalSubdomain=tr">Metehan Yıldırım</a>, Software Engineer @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e65d728d3264" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI / ML: The Race for Specialized Electricity Supremacy]]></title>
            <link>https://synnada.medium.com/ai-ml-the-race-for-specialized-electricity-supremacy-fd53d70703a7?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd53d70703a7</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 17:02:38 GMT</pubDate>
            <atom:updated>2023-08-17T07:53:19.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq59ydH71_gqzQv5dTlWZQ.png" /></figure><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/ai-ml-the-race-for-specialized-electricity-supremacy"><strong>Synnada</strong></a> on April 5, 2023.</blockquote><p>The AI/ML landscape is reminiscent of a gold rush, where everyone is vying for a stake in the game. Like any gold rush, it’s not just about discovering gold, but also providing the shovels. In the next phase of AI/ML, as <a href="https://twitter.com/aronchick/status/1642562779226980353?s=48&amp;t=pQlRzjyJY9zzZ-VJ67aLLg">David Aronchick</a> highlights, this involves supplying “specialized electricity” in the form of compute, storage and networking resources. Numerous startups are emerging in this space, each purporting to have the best shovel(s) in the market. To create scalable, enduring systems and avoid vendor lock-in; engineers must scrutinize the tools they employ and concentrate on discovering the most cost-effective, interoperable, and sustainable solutions.</p><p>Naturally, providers of specialized electricity are incentivized to promote resource consumption as greater consumption translates to increased revenue for them. This unfortunate dynamic fuels innovations that amplify resource consumption while neglecting the utility derived from those resources. We often encounter solutions that promise utility but end up encouraging consumption, ultimately leading to a cycle of waste. Examples include:</p><ul><li>Data movement solutions like ELT/ETL that quickly turn into cost centers [<a href="https://www.reddit.com/r/dataengineering/comments/11xbpjy/beware_of_fivetran_and_other_elt_tools/">1</a>],</li><li>Telemetry/monitoring tools that encourage data replication and ingest at the expense of efficient resource utilization [<a href="https://twitter.com/jamesacowling/status/1636168208377077760?s=20">2</a>],</li><li>Resource-intensive ML solutions like AutoML tools and hyperparameter optimizers that increase resource consumption without necessarily enhancing performance significantly,</li><li>Tool complexity solutions like <a href="https://www.cpard.xyz/posts/mlops_is_mostly_data_engineering/">xOps</a> that add further complexity to <a href="https://www.reddit.com/r/dataengineering/comments/11g3w7v/comment/jaodqh7/?utm_source=share&amp;utm_medium=web2x&amp;context=3">already complex systems</a>, aggravating resource consumption and vendor lock-in issues.</li></ul><p>Numerous industries, both within and outside the tech sector, face analogous challenges and exhibit similar behavioral patterns. This resembles a pendulum swing: There’s a strong initial propensity to gravitate towards a direction where eager adoption of innovations takes priority. However, as adverse effects of these trends become evident, participants start seeking optimization and sustainability — causing the pendulum to swing back towards utility. For the AI space, we predict the following pendulum swing trajectory:</p><ul><li><em>Abundance</em>: We expect a surge in specialized electricity providers catering to the next phase AI/ML transformation, with headlines boasting rapid revenue growth for various companies. This explosion will trigger a wave of innovation and activity, attracting numerous newcomers to the market.</li><li><em>Crunch</em>: As participants recognize their inability to extract desired marginal utility from these specialized electricity providers, they will begin scrutinizing their resource consumptions and try to reduce “waste”. Many providers will fail during this phase, with only those offering genuine utility surviving.</li><li><em>Normalization</em>: The market will stabilize and enter a gestation period in anticipation of the next innovation wave. During this phase, participants will emphasize sustainability, cost-effectiveness and efficiency; seeking tools and solutions that provide long-term value over short-term gains.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x9dMis4n6bb8YMwA.jpeg" /></figure><p>Given that the AI/ML-infra space is ultimately a subset of the B2B data-infra space and each vertical’s pendulum is influenced by its parent vertical, the crunch phase might occur earlier in this domain compared to others. The broader tech world is moving towards a utility phase as companies cut costs and <a href="https://twitter.com/GergelyOrosz/status/1636297339210981377">seek ways to optimize their infrastructure spending</a>. Consequently, we are witnessing the emergence of utility-first players (e.g. Bluesky vs. Snowflake, Edgedelta vs. Splunk and Mezmo vs. Datadog) that are well-positioned to excel in a concentrated market with distinct winners. In this context, we predict the AI/ML-infra space to transition into the crunch regime sooner than one may expect, as the market consolidates and prioritizes sustainable, cost-effective solutions very early-on.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/samican-tandogdu/">Sami Can Tandogdu</a>, COO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd53d70703a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next Frontier: Action-Capable Intelligent Agents]]></title>
            <link>https://synnada.medium.com/next-frontier-action-capable-intelligent-agents-3b80a3636da3?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b80a3636da3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Tue, 25 Apr 2023 17:01:46 GMT</pubDate>
            <atom:updated>2023-08-17T07:56:58.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TSYkheOpiALGDZILGuF1bg.png" /><figcaption>z</figcaption></figure><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/next-frontier-action-capable-intelligent-agents"><strong>Synnada</strong></a> on February 13, 2023.</blockquote><p>The world of AI and data is undergoing a rapid transformation. The traditional approach of batch data analysis for the purpose of converting insights into actionable models is no longer effective due to two key ongoing shifts:</p><ul><li><strong>Real-time data analysis</strong> has become increasingly critical as consumers demand immediate gratification. Gone are the days when streaming data was just a competitive advantage, it is now a necessary aspect of business operations — with entire organizations being built around the principle of real-time operations.</li><li><strong>The advent of versatile AI models such as ChatGPT</strong> has changed the way we approach data-driven systems, enabling the creation of real-time agents that can perform tasks previously reserved for humans. The prospect of fully autonomous intelligent agents operating in real-time has long been a captivating goal that should now be within our reach.</li></ul><p>However, despite recent advancements, the majority of existing solutions continue to be <strong>exclusive and only accessible to a limited group of organizations and/or individuals.</strong> So, what are the challenges and obstacles in democratizing these technological opportunities?</p><h3>Infrastructure Layer</h3><p>The initial challenge we must overcome is within the <strong>infrastructure layer</strong>, which <strong>must effectively and continuously channel data to intelligent agents</strong>. The field of data engineering is facing a growing challenge due to the ever-increasing complexity of tools and technologies — from big data platforms to data ware/lake-housing tools and query engines. This complexity is making it difficult for professionals to stay up-to-date with the latest developments and acquire the necessary skills to excel in the field. The result is a talent gap in the data-driven economy, with organizations struggling to find and retain qualified data engineers to meet the rapidly growing demand.</p><p>This isn’t the first time the industry has <strong>faced a challenge</strong> of this kind. A somewhat similar situation arose with the <strong>adoption of NoSQL databases</strong> in the early 2010s. At the time, there was a clear need for scalable and flexible data management solutions, but engineering talent skilled in these technologies was rare. This caused big data analysis using NoSQL to remain a niche, premium capability for certain breeds of companies for a relatively long time. It wasn’t until prominent players released products with standard SQL support (or at least SQL-like interfaces) that the technology saw widespread adoption by the community, engineers as well as non-engineers like data analysts.</p><p><strong>Stream processing is facing a similar challenge</strong>. Historically, methods for analyzing both at-rest (SQL) and in-motion (non-SQL) data have been separate, leading to slower adoption of stream processing than many had anticipated. Furthermore, even SQL-like interfaces provided by stream processing solutions evolved into their own specific dialects, requiring special functions and features to express data transformations that could be accomplished with standard SQL. This was often driven by a focus on low-latency, real-time use cases, or a desire to use proprietary syntax for competitive advantage. Due to these facts, processing data streams still remains an elusive, esoteric task for many.</p><p>Fortunately, the data ecosystem seems to be moving towards a direction that will help overcome this challenge. The previously popular Lambda architecture, which decouples batch and stream processing, is giving way to the growing popularity of its streaming-first sibling, <strong>Kappa architecture</strong>[<a href="http://milinda.pathirage.org/kappa-architecture.com/">1</a>][<a href="https://www.oreilly.com/radar/questioning-the-lambda-architecture/">2</a>][<a href="https://engineering.linkedin.com/distributed-systems/log-what-every-software-engineer-should-know-about-real-time-datas-unifying">3</a>]. Simplicity, scalability, and lower-latency nature of Kappa notwithstanding, the rise of the event-driven architecture and continuous delivery in software engineering seems to be the main motivating factors behind this shift. This trend presents a great opportunity to solve the challenge in question: If the data infrastructure community interprets and implements the Kappa architecture with a strong unification emphasis, tool complexity may soon start to diminish and the user base of these technologies will grow.</p><p>At Synnada, we strongly support the Kappa architecture and believe that achieving <strong>a real unification of batch and stream processing</strong> is key to the widespread adoption of streaming-first approaches. That’s why we’re working hard to make <strong>streaming capabilities in Apache Datafusion accessible to anyone</strong> with proficiency in standard SQL (and just standard SQL), making it easier to build and maintain real-time data pipelines, applications, or products.</p><h3>Intelligence Layer</h3><p>The second obstacle we need to overcome is within the<strong> intelligence layer</strong>, which <strong>will drive the detections, choices, and actions of the agents</strong>. To ensure an efficient and immediate response, it is crucial that the intelligence layer <strong>operates in real-time</strong>. This requires intelligence subsystems that can quickly process dynamic changes in data, operating conditions, or system behavior. Unfortunately, traditional AI/ML techniques relying on batch processing and training are insufficient in providing the required adaptivity to support <strong>real-time data products.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cMl1MWYT8wA-piGQ.png" /><figcaption>The ML development process is laid out in <a href="https://medium.com/salesforce-ux/the-role-of-design-in-machine-learning-ae968ea90aac">“The Role of Design in Machine Learning”</a> (Owen Shoppe).</figcaption></figure><p>Despite the promising prospects of real-time machine learning, there are still multiple challenges that need to be overcome. One of the biggest hurdles is developing the technology to a point where it can seamlessly integrate into data engineering workflows and eventually, data products.</p><p>So, what does real-time machine learning <strong>really</strong> mean? We see several <strong>key criteria for real-time ML systems</strong>:</p><ul><li>A real-time ML system must have a low prediction latency, as it should be able to process new data and make predictions over data streams in near real-time.</li><li>Continuous learning is a key aspect of a real-time ML system, as it should be able to learn from data streams incrementally and perform model updates quickly. This is especially critical for applications where data drifts and regime changes are common.</li><li>Real-time ML systems should exhibit self-guidance, assign confidences to their predictions, and have the ability to make justified decisions on the fly.</li><li>Furthermore, real-time ML systems should have excellent robustness properties, not only when inferencing but also during training. Currently, training of a typical ML system is generally a fragile, trial-and-error driven process that often involves some type of brute-force style search over hyper-parameters. Such approaches will need to be eclipsed by other methods in viable real-time ML systems.</li><li><a href="https://hai.stanford.edu/news/humans-loop-design-interactive-ai-systems">Human-in-the-loop</a> (HITL) capabilities are crucial to cover cases where real-time ML systems do not have enough confidence to take certain actions, and should defer to humans. Moreover, HITL also facilitates efficient continuous learning. The field of reinforcement learning has a rich literature on various techniques one can utilize for this purpose.</li><li>Finally, the cost of designing and deploying real-time ML systems is another critical aspect that must be taken into consideration in practice. This includes not only the cost of hardware and software resources required to run the system, but also the cost of expert knowledge and expertise needed to develop, implement, and maintain the system.</li></ul><p>Today people try to utilize, or should we maybe say force, ideas like AutoML [<a href="https://arxiv.org/pdf/1908.00709.pdf">1</a>][<a href="https://alexandruburlacu.github.io/posts/2022-07-05-neptuneai-automl">2</a>][<a href="https://towardsdatascience.com/automl-is-overhyped-1b5511ded65f">3</a>] from traditional off-line ML into the real-time ML area because that is all they have. Obviously, such approaches do not work well and have resulted in a whole plethora of auxiliary ML products, such as model monitoring tools, <a href="https://www.mihaileric.com/posts/mlops-is-a-mess/">MLOps</a> platforms and others.</p><p>Imagine we use an AutoML system to continually update our models — how costly (and slow) would that be? Think about trying to collect new, relevant labels every time when your model monitoring tool warns you that your model is going out of sync. If you had a working HITL system in the first place, there would be no need for doing this.</p><p>At Synnada, we are working on a comprehensive real-time ML framework that meets all these criteria by incorporating either (1) novel research, or (2) best practices from the industry. You will not need to integrate multiple ML tools while building data products — this ML framework will seamlessly mesh with our data streaming technology so our users will start benefiting from the underlying synergies from day one without getting into any complicated integration work.</p><p>If you are interested, follow us so that we can keep you in the loop about our most recent ML R&amp;D. These days, we are focusing on robust optimization techniques that will serve as the main workhorse of the full framework, and we plan to discuss our results soon.</p><h3>Product Layer</h3><p>As we progress towards developing intelligent agents/systems that have the ability to observe, decide, act, and continuously adapt; the final obstacle to overcome is to package and deliver these agents for practical use. Our goal must be to deliver a rich selection of useful agents that should, over time, specialize to the environment of each end-user. We believe such a goal could only be achieved through a product layer [<a href="https://towardsdatascience.com/designing-data-products-b6b93edf3d23">1</a>][<a href="https://www.montecarlodata.com/blog-how-to-treat-your-data-as-a-product/">2</a>] that would allow a <a href="https://www.thoughtworks.com/insights/articles/how-implement-hypothesis-driven-development">”test, learn and improve” cycle</a> of building and servicing. So, what is required from such a layer?</p><p>Composability is a key aspect for any framework that aims to facilitate development of intelligent agents. There is a very large universe of use cases we want to create agents for, and every use case requires some customization and/or specialization in one way or another. Therefore, it is essential to embrace a flexible and composable approach, so that users can create agents that fit best to their specific needs by combining elementary components. As an example, imagine that we are building an end-to-end DevOps agent to help us with initial triaging. It would likely need to carry out tasks such as analyzing logs, forecasting metrics, or responding to support inquiries, each of which requires a specific AI subsystem we would need to compose together.</p><p>Another key requirement is an effective collaboration layer: Features such as comprehensive version control for data, models, and code; data management and organization functions accessible to non-technical users; support structures for ML engineers and data engineers; and cross-functional teamwork mechanisms are crucial for development, maintenance and effective operation of intelligent agents (and data systems in general). Moreover, this collaboration layer will also be responsible for facilitating intuitive interactions between<a href="https://dl.acm.org/doi/pdf/10.1145/3313831.3376301"> AI agents and humans</a> so that users can equip their agents with effective human-in-the-loop capabilities.</p><p>Overall, the development of advanced data/AI systems requires a compound product strategy that addresses the key components of collaboration, composability, and other non-functional (such as auditability &amp; control, explainability, governance, serviceability, deployment, scaling, etc.) requirements. Each of these components must be given the necessary attention, designed for maximum efficiency and delivered in a tightly-knit manner, as they are all essential for unlocking the full capabilities of a live system. Adding such features as an afterthought will, eventually, reduce the robustness and effectiveness of intelligent agents. Synnada understands the need for a full-scope solution and is planning to deploy a compound product strategy to meet the demands of the ever-evolving data and AI spaces.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/samican-tandogdu/">Sami Can Tandogdu</a>, COO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b80a3636da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[General-purpose Stream Joins via Pruning Symmetric Hash Joins]]></title>
            <link>https://synnada.medium.com/general-purpose-stream-joins-via-pruning-symmetric-hash-joins-94cc69a4847?source=rss-9989aaa4833d------2</link>
            <guid isPermaLink="false">https://medium.com/p/94cc69a4847</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[stream-processing]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Synnada]]></dc:creator>
            <pubDate>Fri, 21 Apr 2023 17:02:13 GMT</pubDate>
            <atom:updated>2023-08-17T07:52:31.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gplQn6XSLzn579MclNDd6A.png" /></figure><blockquote>This article was originally published on <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>Synnada</strong></a> on February 20, 2023 and is part of our ongoing series on streaming SQL engines and advanced join algorithms. In previous posts, we discussed techniques like <a href="https://www.synnada.ai/blog/probabilistic-data-structures-in-streaming-count-min-sketch"><strong>Probabilistic Data Structures in Streaming: Count-Min Sketch</strong></a> and <a href="https://www.synnada.ai/blog/general-purpose-stream-joins-via-pruning-symmetric-hash-joins"><strong>The Sliding Window Hash Join Algorithm: Efficiently Joining Infinite Streams with Order Preservation</strong></a> and <a href="https://medium.com/@synnada/running-windowing-queries-in-stream-processing-93068d3a5"><strong>Running Windowing Queries in Stream Processing</strong></a> that serve as building blocks. The concepts discussed in this series are implemented in Apache Arrow/DataFusion, which has a bunch of other cool features we haven’t talked about yet.</blockquote><p>As the Lambda architecture that separates batch and stream processing systems gives way to the Kappa architecture which argues for a unified approach, a significant amount of attention is again focusing on stream joins in the data space. At Synnada, we strongly support the ideas and motivations behind the Kappa architecture, and we have been working hard on readying Apache Datafusion for this transformation.</p><p>Today, we are excited to announce the addition of Symmetric Hash Join to Apache Datafusion. This new feature will greatly enhance the capabilities of our query processing engine and give users even more powerful tools for querying, analyzing, and managing large datasets in real time.</p><p>Symmetric Hash Join will integrate into DataFusion’s existing API seamlessly, fully compatible with Datafusion’s existing static data sources and streams. Whether you have static data with cardinality constraints or streaming data, Symmetric Hash Join will help you process large datasets faster and more efficiently, enabling you to generate low-latency, data-driven results.</p><p>Our implementation of this feature includes an advanced optimization technique called build-side pruning, which allows the algorithm to detect early on when certain rows no longer matter to the join result and remove them from memory. This results in a significant performance boost and more efficient use of computational resources.</p><p>In this blog post, we’ll take a closer look at the Symmetric Hash Join algorithm. We will explain how it works, its advantages, and the benefits of using it. We’ll also show you how to use it in your Datafusion pipeline and provide tips and tricks for getting the most out of it.</p><p>We hope that this new addition will help you to achieve your big data goals more easily and with greater speed, and we welcome your feedback and questions.</p><h3>Symmetric Hash Join</h3><h3>A brief explanation</h3><p>To explain the Symmetric Hash Join (SHJ) algorithm, let’s first quickly remind ourselves how the ordinary <a href="https://en.wikipedia.org/wiki/Hash_join">Hash Join</a> algorithm works. At a high-level, the latter works in a two-step fashion: It first consumes one of its inputs (the build side) to build a hash table, and then consults this hash table while consuming its other input (the probe side) to determine matches. The SHJ algorithm eliminates this build/probe side asymmetry by maintaining a hash table for each input, and consults these tables continuously as it consumes both its inputs.</p><h3>When is it appropriate?</h3><p>The SHJ algorithm is typically useful when quick response times are needed, or when inputs are unbounded. It can be used in various types of data processing tasks, such as:</p><ul><li><strong>Real-time streaming</strong>: The SHJ algorithm can be used in real-time streaming scenarios to join data from multiple streams with low latency. For example, it can be used to join data from IoT devices with data from other sources, such as weather data.</li><li><strong>Large datasets with low cardinality</strong>: The SHJ algorithm can be used to join large datasets with low cardinality by exploiting sliding window join properties. When the low cardinality columns are used as keys in sliding window joins, a lot of unnecessary computational work is done when we first check the equality, making the join operation inefficient. This can lead to long processing times and high resource usage, making it difficult to meet low-latency processing requirements.</li></ul><h3>How does it work?</h3><h4>Context: Query processing and streams</h4><p>In a query processing engine, data flows in between different operators or stages within the engine, and each operator or stage performs a specific operation on the data. The query planning step is responsible for determining the optimal execution plan for the query, which simply means selecting the applicable operators, configuring them and connecting them in some optimal sense.</p><p>However, when processing streams, this is not as straightforward as it sounds, since not all operators are stream-friendly. Stream-unfriendly operators are often called <em>pipeline-breaking</em> operators, and we need to get the job done by utilizing only stream-friendly operators that allow our data streams to flow smoothly through the entire pipeline.</p><p>This means that none of our operators should block processing by waiting for a large amount of input data without producing any output, or by writing intermediate results to disk (if possible). While some operations (such as sorting) are inherently not compatible with this concept (and thus are pipeline-breaking), many use cases allow solutions involving only stream-friendly operators.</p><h4>Joins and streams</h4><p>Are join operators pipeline-breaking? To answer this question, let’s imagine a scenario where we have static data on one side, and a stream on the other:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*_8YjhP63GlKDgv-sFthOyQ.png" /><figcaption>Figure 1: Ordinary Hash Join algorithm in Datafusion.</figcaption></figure><p>The current implementation of the ordinary Hash Join algorithm in Datafusion (and in many other engines) materializes the entire left side as the build side, constructing the hash table only once and allowing the right side to stream. The implementation also supports the converse case by simply swapping sides. Circling back to our question, we see that the answer is yes for the build side, and no for the probe side.</p><p>Obviously, materializing one side is not an option if both sides are infinite streams — enter the SHJ algorithm, which <em>partially</em> materializes both sides incrementally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*TuKDmwDQn8U3T1XTa807QQ.png" /><figcaption>Figure 2: Partial materialization on both sides.</figcaption></figure><p>This makes SHJ stream-friendly for both sides. However, it still does not give us a carte-blanche to join two infinite streams in general. If we did that, the hash tables would simply grow over time and we would eventually run out of memory. Therefore, there needs to be a mechanism to limit the sizes of these tables if we were to ever use the SHJ algorithm on infinite streams.</p><p>Fortunately, a stream join is performed on a finite time window in many practical use cases, which gives us an avenue to limit sizes of these hash tables. We can employ SHJ so long as the inner batch buffer is flushed frequently in accordance with the finite sliding window, maintaining a compact hash table.</p><p>Obviously, if we have some other join filtering logic that limits table sizes instead of a sliding time window, we would need to flush according to that filtering logic. Therefore, to solve this task in a generic fashion, one needs a way to calculate bounds on arbitrary expressions when certain favorable conditions are present in the data stream (like increasing timestamps/column values).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lyf8aPER-5MRBSNprXM2XQ.png" /><figcaption>Figure 3: A new RecordBatch arrives on one side.</figcaption></figure><blockquote>⚠️ For more information about stream processing methods, see: [1] Mironov, Eugene. “In-Stream Big Data Processing.” Highly Scalable Blog, 20 Aug. 2013, <a href="https://highlyscalable.wordpress.com/2013/08/20/in-stream-big-data-processing/">https://highlyscalable.wordpress.com/2013/08/20/in-stream-big-data-processing/</a></blockquote><p>The figure above explains what happens when a new collection of rows (called a RecordBatch in Datafusion) arrives on one side:</p><ol><li>We use the join keys to look up the corresponding row on the other side’s inner buffer (hash table). If a match is found, the rows are joined and recorded as visited.</li><li>We prune the rows that fall outside the range of possible join key values.</li></ol><p>As long as we maintain a reasonably sized inner buffer for each side and there is some filtering that limits buffer sizes, infinite streams can be joined correctly just like static data.</p><h4>Existing Symmetric Hash Join implementations</h4><pre>SELECT * FROM left_table, right_table<br>WHERE<br>    left_key = right_key AND<br>    left_time &gt; right_time - INTERVAL 12 MINUTES AND<br>    left_time &lt; right_time + INTERVAL 2 HOURIn a typical stream processing library like Apache Flink or Apache Spark, the join operation can be performed using watermarks. Let’s examine a query taken from the Apache Spark docstring:</pre><blockquote>In this query (), say each join side has a time column, named “left_time” and “right_time”, and there is a join condition “left_time &gt; right_time — 8 min”. While processing, say the watermark on the right input is “12:34”. This means that from henceforth, only right inputs rows with “right_time &gt; 12:34” will be processed, and any older rows will be considered as “too late” and therefore dropped. Then, the left side buffer only needs to keep rows where “left_time &gt; right_time — 8 min &gt; 12:34–8m &gt; 12:26”. That is, the left state watermark is 12:26, and any rows older than that can be dropped from the state. In other words, the operator will discard all states where the timestamp in state value (input rows) &lt; state watermark.</blockquote><p>Actually, this is part of the picture, not the whole. In theory, range-based pruning can be done with any sorted field (not just the watermark field) and with any arbitrary join filter condition that is amenable to this type of data pruning. However, Apache Spark overfits to timestamps and associates the pruning operation with a watermark. Let’s follow a different approach and examine the following query from a more general, first-principles perspective:</p><pre>SELECT * FROM left_table, right_table <br>WHERE <br>  left_key = right_key AND<br>  left_sorted &gt; right_sorted - 3 AND<br>  left_sorted &lt; right_sorted + 10</pre><p>If sort orders of the two columns (left_sorted and right_sorted) are ascending, and the join condition is left_sorted &gt; right_sorted — 3, and the latest value on the right input is 1234, then the left side buffer only has to keep rows where left_sorted &gt; 1231 and any rows coming before this boundary can be dropped from the buffer. Note that this example is in no way specific; similar scenarios can manifest with a variety of orderings and join filter expressions.</p><p>This becomes very powerful when we consider unified batch and stream processing as range conditions can be used in a wide variety of use cases. Let’s examine a slightly more complex join:</p><pre>SELECT * FROM left_table, right_table<br>WHERE<br>  left_key = right_key AND<br>  left_1 + left_2 &gt; right_sorted - 3 AND<br>  left_1 + left_2 &lt; right_sorted + 10</pre><p>If sort orders of the two expressions (left_1 + left_2 and right_sorted) are ascending, we can still prune each side. However, calculating the expression/variable bounds might be challenging since the involved math is now getting more complex. In our work, we applied a well-known, systematic approach from the domain of mathematical optimization to this context, using interval arithmetic to calculate expression bounds and constraint propagation to refine variable bounds.</p><h3>Interval Arithmetic</h3><p>Interval arithmetic is a numeric technique used by many successful global optimization and equation-solving algorithms. It extends ordinary arithmetic to interval values, similar to how ternary logic extends boolean logic. Following the rules of interval arithmetic, one can estimate the range of possible values an expression can take on in a single evaluation pass. Optimizers and solvers utilize this capability to eliminate infeasible regions of their search spaces early on so as to focus on viable regions. In the context of SHJ, we will use interval arithmetic to prune non-viable rows from our hash tables.</p><blockquote>⚠️ For more information about interval arithmetic, see: [2] Kabak, Mehmet Ozan. Analog Circuit Start-Up Behavior Analysis: An Interval Arithmetic Based Approach, Chapter 4. Stanford University, 2015. [3] Moore, Ramon E. Interval analysis. Vol. 4. Englewood Cliffs: Prentice-Hall, 1966.</blockquote><h4>Interval operators</h4><p>Interval arithmetic provides a set of mathematical operators that can be used to perform calculations on intervals. These operators include basic arithmetic operations such as addition, subtraction, multiplication, and division, as well as more advanced operations such as intersection, union, and set difference. One can compose these operators to calculate the range of possible values for a function in a specific region of the search space, facilitating rapid identification and elimination of infeasible regions of the search space. The elementary arithmetic operations are defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mB_K0ExBHhDwzo_EkFAlSg.png" /></figure><p>It also possible to define interval operators for more complex operations such as trigonometric functions, exponentials and logarithms, roots, etc.</p><h4>Interval calculations</h4><p>Interval arithmetic provides a structured approach to calculating the bounds of a complex expression by combining the bounds of its simpler components. This hierarchical computation is well-suited for a graph-based implementation, where an equation system is represented by a directed acyclic expression graph (DAEG). In this graph, each leaf node corresponds to a variable (or a constant), and each root node corresponds to an individual equation or constraint. The internal nodes represent intermediate terms in the equations/constraints and may be shared among multiple root nodes.</p><p>In our implementation, each node contains the physical expression itself and an interval [L, U]. Interval [L, U] indicates the computed bounds for the node. By using this structure, the desired hierarchical computation procedure can be achieved by simply performing a bottom-up evaluation of the graph, also known as a post-order traversal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M3K0ThLFOVbbrf-zBgvCnw.png" /><figcaption>Figure 4: Bottom-up interval calculation.</figcaption></figure><h4>Constraint Propagation</h4><p>After executing a bottom-up traversal on the expression graph, we obtain interval bounds for each node, with the root node ultimately corresponding to the full join filter condition. With these intervals in place, we can then propagate constraints from parent nodes to child nodes via a subsequent top-down traversal, which enables us to shrink expression intervals when possible. In this top-down traversal, we use the following propagation rules:</p><ul><li><em>z = x</em> + <em>y → x</em> ∈ <strong><em>X</em></strong><em> ∩</em> (<strong><em>Z</em></strong> — <strong><em>Y</em></strong>) ∧ <em>y</em> ∈ <strong><em>Y</em></strong><em> ∩</em> (<strong><em>Z</em></strong> — <strong><em>X</em></strong>)</li><li><em>z</em> = <em>x</em> — <em>y</em> <em>→ x</em> ∈ <strong><em>X</em></strong><em> ∩</em> (<strong><em>Z</em></strong> + <strong><em>Y</em></strong>) ∧ <em>y</em> ∈ <strong><em>Y</em></strong><em> ∩</em> (<strong><em>X — Z</em></strong>)</li><li><em>z</em> = <em>x</em> × <em>y</em> <em>→ x</em> ∈ <strong><em>X</em></strong><em> ∩</em> (<strong><em>Z</em></strong> ÷ <strong><em>Y</em></strong>) ∧ <em>y</em> ∈ <strong><em>Y</em></strong><em> ∩</em> (<strong><em>Z</em></strong> ÷ <strong><em>X</em></strong>)</li><li><em>z</em> = <em>x</em> ÷ <em>y</em> <em>→ x</em> ∈ <strong><em>X</em></strong><em> ∩</em> (<strong><em>Z</em></strong> × <strong><em>Y</em></strong>) ∧ <em>y</em> ∈ <strong><em>Y</em></strong><em> ∩</em> (<strong><em>X</em></strong> ÷ <strong><em>Z</em></strong>)</li></ul><p>Basically, these rules enable us to propagate a constraint, placed on the result of an operation, to the arguments of the operation. Since we are in possession of the entire expression graph (i.e. the DAEG), we can use these rules to propagate each of our equality or inequality constraints (i.e. f(x) = 0, f(x) &gt; 0 etc.) all the way down to the variables (i.e. columns).</p><p>To illustrate in the context of a concrete example, we revisit the example from Figure 4. Only this time, we analyze it from the constraint propagation perspective. Particularly, consider the equality condition x² + y = 4, where intervals of x and y are [1, 2] and [-3, 1] respectively. Assume that we have just finished our bottom-up evaluation of the DAEG. To propagate the mentioned equality constraint, we just perform an additional, top-down evaluation of the DAEG using the rules above. You can inspect the details of this procedure in Figure 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shjYwrG7eeVl5Vo691WNjw.png" /><figcaption>Figure 5: Top-down interval propagation.</figcaption></figure><h4>Use Case: Join Filters</h4><p>Having gone through the basics of interval calculations, let’s take a look at how we can make use of these techniques on join filters for the purposes of data pruning. Consider the following query:</p><pre>SELECT * FROM left_t, right_t<br>WHERE <br>  left_t_key = right_t_key AND<br>  left_t.a &gt; right_t.b - 3 AND<br>  left_t.a &lt; right_t.b + 10</pre><p>This query will produce the following DAEG:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*YputA7cZkgUoHbtRUPgdvg.png" /><figcaption>Figure 6: Produced DAEG.</figcaption></figure><p>Every time we process a row (or a batch of rows depending on the batch size) within the SHJ algorithm, we need to compute viable ranges for a and b so that we can limit our buffer sizes. For this purpose, we will first evaluate the DAEG bottom-up, and then propagate the constraint that the logical conjunction is true from the root node top-down. Interested in even more details of how this happens? Read on.</p><h3>Buffer Pruning with Interval Arithmetic</h3><p>Consider the following query:</p><pre>SELECT * FROM left_t, right_t <br>WHsERE <br>  left_t_key = right_t_key AND<br>  left_t.a &gt; right_t.b - 3 AND<br>  left_t.a &lt; right_t.b + 10</pre><p>When a new RecordBatch arrives at the right side, the condition a &gt; b — 3 will possibly indicate a prunable range for the left side. Conversely, when a new RecordBatch arrives at the left side, the condition a &lt; b + 10 will possibly indicate prunability for the right side. In general, every inequality condition will indicate prunability for one side of the join. As sliding window filters involve two inequalities with opposite directions, we can prune both sides as we consume the inputs. Note that a more stringent composite join condition works in favor of prunability; we get more opportunities for pruning if we have a conjunction of many sub-conditions.</p><p>Now, let’s go through a concrete example. Assuming that the left side is the build side (i.e. a new RecordBatch arrives at the right side), we can picture the process as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*ACuaQrpA2ZVl2VDEhyh4nQ.png" /><figcaption>Figure 7: Build side joinable range.</figcaption></figure><p>How exactly do we use interval arithmetic for pruning here? This is done by first creating an interval for join filter values on the build side of the join, which spans [- <strong>∞</strong>, FV] or [FV, <strong>∞</strong>] depending on the ordering (descending/ascending) of the filter expression. Here, FV denotes the first value on the build side. This range is then compared with the probe side interval, which either spans [- <strong>∞</strong>, LV] or [LV, <strong>∞</strong>] depending on the ordering (ascending/descending) of the probe side. Here, LV denotes the last value on the probe side.</p><p>Going back to our concrete example,</p><ul><li>The interval for column a is [1, ∞] (as the first a value on the left is 1),</li><li>The interval for column b is [6, ∞] (as the latest b value in the newly arriving batch is 6).</li></ul><p>Then, we evaluate the join conditions using interval arithmetic, and propagate the constraint by traversing the expression graph top-down. In this specific example, only column a’s range shrinks, and its new interval becomes [3, ∞] while the interval for column b does not change. Once these new intervals are computed, they are then used to determine which rows in the build side can be safely discarded without affecting the final join result. These rows are subsequently removed from the buffers since they can never match with any probe-side row in the future.</p><h3>Generating unmatched row results</h3><h4>Context: Inner and Outer joins</h4><p>Inner join is a type of join that returns only the records that have a match in both tables. This type of join is used when both tables have related data that needs to be matched between the two tables.</p><p>Left/right outer joins return all the records from one of the tables, even if there is no match in the other table. In other words, left (right) join returns all the records from the left (right) table and the matching records from the right (left) table (if any). There is also a full outer join, which returns all the records from both the tables, whether there is a match or not.</p><p>Consider two tables, Table1 and Table2, with the following data:</p><p>Table1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*Ukt3mnNwVT01cA0oYSGdPw.png" /></figure><p>Table2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*aE_RkeoMt-arDQDZLdudHw.png" /></figure><p>A query computing a left join of Table1 and Table2 on the a column looks like:</p><pre>SELECT a, Table1.b, Table2.b<br>FROM Table1<br>LEFT JOIN Table2<br>ON Table1.a = Table2.a;</pre><p>which would generate a result like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*oXt_rZMBtNiMXZ5BHst3EA.png" /></figure><p>As you can see, the result includes all the rows from Table1 and the matching rows from Table2. Note that the last row has a NULL value for the column Table2.b, because there was no matching row for it in Table2. For more examples, see the <a href="https://en.wikipedia.org/wiki/Join_(SQL)#Outer_join">Wikipedia article explaining outer joins.</a></p><h4>Outer joins and infinite streams</h4><p>When (outer) joining infinite streams, special care has to be taken when dealing with unmatched rows. If we are executing vanilla SHJ on data without ordering guarantees, a currently-unmatched row can always have a matching result in the future as new data comes in. However, when operating on data that lends itself to pruning, we can gracefully handle unmatched rows incrementally: Whenever we decide that a part of the inner buffer is not joinable in the future, we can check the expiring rows to see if they were matched before. If not, we can generate the necessary output consisting of any unmatched rows right there and then, allowing incremental processing.</p><h3>Performance analysis</h3><p>Whenever join conditions and data ordering lends itself to pruning (e.g. sliding window filtering), we expect SHJ to exhibit higher performance than ordinary Hash Join, since it requires less memory. In many cases, SHJ can perform the join entirely in memory while ordinary Hash Join can not. This is certainly true for unbounded streams; but it is also possible with large, static data if join conditions and data ordering are favorable.</p><p>An intelligent query planning algorithm should inspect data ordering, nature of the join conditions, and join key cardinality when choosing between SHJ and ordinary HJ. This decision can also be analyzed within a cost-based optimization framework, which is topic we plan to discuss in the future.</p><h3>Experiment setup</h3><p>When comparing the performance of SHJ and ordinary Hash Join algorithms in terms of execution time, there are three important parameters to consider: Batch size of the data, cardinality of the join key, and obviously the table size.</p><p>Batch size of the data refers to the number of rows we process in a single iteration of the join operation. A larger batch size can result in a more efficient join operation, as more data can be processed at once. However, a larger batch size can also decrease the number of prune operations, thus it may increase transient memory usage and reduce cache efficiency.</p><p>Cardinality of the join key refers to the number of unique values the join key can take. A lower cardinality can result in fewer hash table entries. However, since Datafusion’s current Hash Join implementation (called HashJoinExec) relies on a total join calculation before filtering, the intermediate result can be huge, increasing execution time and memory consumption dramatically.</p><p>Table size refers to the number of rows in each table involved in the join operation. A larger table size result in longer execution times, as there are more rows to process.</p><p>Considering these parameters in our study, we can get a relatively comprehensive view algorithmic performance for both SHJ and ordinary Hash Join algorithms.</p><p>To highlight the importance of build-side pruning, we will be using a query with a sliding window filter, which reads:</p><pre>l.sorted_ascending + 1 &gt; r.sorted_ascending + 5 AND<br>l.sorted_ascending + 3 &lt; r.sorted_ascending + 10</pre><p>The input tables are created by the following code:</p><pre>let initial_range = 0..table_size;<br>let left_batch = build_record_batch(vec![ <br>  ( <br>    &quot;key&quot;, <br>    Arc::new(Int32Array::from_iter( <br>      initial_range.clone().map(|_| rng.gen_range(0..cardinality)).collect::&gt;(), <br>    )), <br>    ), <br>  ( <br>    &quot;sorted_ascending&quot;,<br>    Arc::new(Int32Array::from_iter(<br>      initial_range.clone().map(|x| {<br>        if rng.gen_bool(0.3) &amp;&amp; x &gt; 0 {x-1} else {x}<br>      }).collect::&gt;(),<br>    )),<br>  ),<br>  ])?;<br>let right_batch = build_record_batch(vec![<br>  (<br>    &quot;key&quot;,<br>    Arc::new(Int32Array::from_iter(<br>      initial_range.clone().map(|_| rng.gen_range(0..cardinality)).collect::&gt;(), <br>    )),<br>    ),<br>  (<br>    &quot;sorted_ascending&quot;,<br>    Arc::new(Int32Array::from_iter(<br>      initial_range.clone().map(|x| {<br>        if rng.gen_bool(0.3) &amp;&amp; x &gt; 0 {x-1} else {x}<br>      }).collect::&gt;(),<br>    )),<br>    ),<br>  // Low cardinality column<br>])?;</pre><p>The parameter set is selected as</p><ul><li>Join type: Inner join,</li><li>Batch size: 128, 512, 2048, 4096,</li><li>Cardinality: 8 (Low), 64(Medium), 1024(High),</li><li>Table size: 8192, 16384, 32768, 65536.</li></ul><h3>Low cardinality</h3><p>In this case, we are expecting HashJoinExec) to perform badly, since it is operating under very unfavorable conditions resulting in intermediate batch building and then filtering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JBP3faIr7jJGNvdLH-gSg.png" /></figure><p>We can see that the efficient inner buffers of SymmetricHashJoinExec makes intermediate batch building much faster. We maintain a nearly constant-size buffer for this use case.</p><h3>Medium cardinality</h3><p>In this case, we are expecting HashJoinExec to perform relatively better than the previous setting, since the intermediate batch size gets smaller. However, the superlinear nature of the operation remains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hn8k4U5rdpZZmqNX-RWktA.png" /></figure><p>Again, we get much higher performance from SymmetricHashJoinExec due to low buffer sizes.</p><h3>High cardinality</h3><p>As cardinality increases, we get better results in terms of execution time from both algorithms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DprgfgF0YItuNxZjSq-2Q.png" /></figure><p>However, the superlinear nature of HashJoinExec does not change, and the performance improvement persists.</p><h3>Future roadmap</h3><p>Our initial implementation for Apache Datafusion does not include all of the potential benefits of the SHJ algorithm. The main features included in our initial PR are:</p><ul><li>An initial library for interval arithmetic, which includes basic arithmetic operations (addition and subtraction) and comparison operations (greater than and less than) for integer types, and supports the logical conjunction operator.</li><li>An API for performing interval calculations, which can be used for other purposes, such as range pruning in Parquet. Within the context of this PR, we use this functionality to calculate filter expression bounds for pruning purposes.</li><li>A constraint propagation module to construct expression DAGs from physical expression trees and update column bounds efficiently for data pruning purposes.</li><li>An initial implementation of SHJ, which is limited to the partitioned mode and does not yet have full support for output order information.</li><li>A new physical optimization sub rule for to utilize SHJ instead of ordinary Hash Join when joining two (unbounded) streams.</li></ul><p>In order to have a PR with a manageable size, some features have been excluded for now, but will be added in the future. These include:</p><ul><li>Improved support for interval arithmetic, such as support for open/closed intervals, multiply/divide operations, additional comparison and logical operators, floating point numbers, and time intervals.</li><li>Improved constant propagation, including the ability to determine monotonicity properties of complex physical expression trees.</li><li>An improved SHJ algorithm, including support for collect left/right/all modes, intermediate buffers for complex expressions, and an improved output ordering flag.</li></ul><h3>Parting words</h3><p>When we first contemplated to write this blog post, we had two goals: (1) Announcing a cool algorithmic contribution to Apache Datafusion, and (2) creating a good resource for anyone who has an interest in stream joins. For these purposes, we dug deep into the Symmetric Hash Join algorithm, explaining how it works at a relatively accessible format. We also discussed how optimizations such as build-side pruning work, and showed why/how these optimizations result in better performance and lower resource utilization.</p><p>We believe that this new feature will be a valuable addition to Apache Datafusion, as it will improve join performance on large datasets and create new opportunities when working with unbounded stream data. If you have any questions, comments, or ideas for further improvements to either SHJ or Datafusion in general, feel free to reach out to us.</p><h3>Authors</h3><ul><li><a href="https://www.linkedin.com/in/meteyyildirim/?originalSubdomain=tr">Metehan Yıldırım</a>, Software Engineer @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/mehmet-ozan-kabak-ph-d-b2a38b4a/">Mehmet Ozan Kabak</a>, CEO and Founder @ <a href="https://www.synnada.ai/">Synnada</a></li><li><a href="https://www.linkedin.com/in/akurmustafa/?originalSubdomain=tr">Mustafa Akur</a>, Software Engineer @ <a href="https://www.synnada.ai/">Synnada</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94cc69a4847" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>