<?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 Miguel Liroz on Medium]]></title>
        <description><![CDATA[Stories by Miguel Liroz on Medium]]></description>
        <link>https://medium.com/@mliroz?source=rss-a0f5c7cb9cce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JISCUWkvrXS_wjjIy_Z7Cw.jpeg</url>
            <title>Stories by Miguel Liroz on Medium</title>
            <link>https://medium.com/@mliroz?source=rss-a0f5c7cb9cce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:18:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mliroz/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[How we compute data lineage at Criteo]]></title>
            <link>https://medium.com/criteo-engineering/how-we-compute-data-lineage-at-criteo-b3f09fc5c577?source=rss-a0f5c7cb9cce------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3f09fc5c577</guid>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[data-catalog]]></category>
            <dc:creator><![CDATA[Miguel Liroz]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 07:06:01 GMT</pubDate>
            <atom:updated>2023-12-11T14:24:00.680Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D8H8XokCN7jKb2vN" /><figcaption>Photo by <a href="https://unsplash.com/@boliviainteligente?utm_source=medium&amp;utm_medium=referral">BoliviaInteligente</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://en.wikipedia.org/wiki/Data_lineage">Data lineage</a> is the process of understanding how data flows from sources to consumption. Providing a service that allows to track and expose this information is invaluable in any data-centric organization and it enables the automation of many use cases and processes. This is why this is a topic that has received plenty of attention in recent years. However, even if the concept and uses are well understood, the actual technical implementation of a system providing this information is complex and messy. In this article, we describe how we have iteratively built this service in Criteo and how much we are able to track with it.</p><h3>What is data lineage and why is it useful</h3><p>We distinguish two types of access to the data, and we track both: <em>lineage</em>, which detects the relationships between two data assets, where one is used / transformed to produce the other, and <em>usage</em>, where the data is accessed but no asset is produced directly (e.g., a user doing an ad-hoc query). Sometimes in the literature, both are referred to as lineage, but internally we make the difference explicit when presenting it to our users.</p><p>Lineage is presented at different granularities:</p><ul><li><strong>Table / data asset lineage:</strong> We track a relationship between two data assets. This relationship has a direction, where the source data asset is used to produce a destination data asset. Note that typically the name <em>table lineage</em> is used, but we consider it to be a more general concept as it includes data assets that are not backed up by tables or BI reports / dashboards.</li><li><strong>Partition lineage:</strong> Given their volume, most of our datasets are partitioned and computed incrementally. We can track lineage relationships between partitions from source and destination datasets; in other words, which are the partitions that were used / transformed to generate a target partition on the destination.</li><li><strong>Column lineage:</strong> In this case, we track the relationships between individual columns within source and destination datasets. In some cases, we are also able to expose the nature of the relationship, the impact being different if we are just projecting or transforming a column or if we are using it within a <em>where</em> expression to filter out the rows of the output.</li></ul><p>At Criteo, lineage enables multiple use cases that are similar to the <a href="https://atlan.com/data-lineage-explained/">usages in the industry</a>:</p><ul><li><em>Impact analysis</em>, both to obtain the list of impacted data assets during a data incident and to perform safe changes to our schemas and workflows.</li><li><em>Root cause analysis</em>, mainly to help solve incidents.</li><li><em>Usage analysis,</em> to track access to our data assets, remove unused ones and calculate an ROI.</li><li><em>Regulatory compliance</em>, allowing us to perform auditing and PII tracking.</li><li><em>Enhance metadata</em>, as lineage is merged with many other metadata and exposed to provide high-level insights.</li></ul><p>We expose lineage in two different ways: through a series of datasets containing low-level details and through a user-friendly application that provides both data catalog and data observability functionalities.</p><p>At Criteo we expose very detailed and thorough information about the usage of our data platform within our own data platform. We call this the <em>metrology pipeline</em>, and it includes a rich collection of datasets providing information about the contents of our storage, the executions (applications, queries, jobs, workflows), and the lineage / usage. This pipeline not only extracts this information from our systems but also crosses the different sources to facilitate their analysis. As a consequence, lineage information is exposed on specific datasets but is also combined with information about the queries / jobs / applications that generated those lineage relationships.</p><p>Obviously, accessing this low-level data is not simple, and only a handful of people do it on a regular basis. As in many other organizations, we provide a user-friendly web application that acts both as a data catalog and a data observability service. This application is called <em>Datadoc</em> and we have been working on it for years, so it has significantly evolved <a href="https://medium.com/criteo-engineering/datadoc-the-criteo-data-observability-platform-2cd826a9a1af">since we presented it for the first time</a>. Datadoc consumes the lineage information from the metrology pipeline and exposes it through an API and a series of views, combined with other metadata. As opposed to the metrology pipeline, this application is used by hundreds of users, including data engineers, data analysts, data governance actors, and other engineers in our R&amp;D and other departments.</p><p>Some examples of how the lineage is used in Datadoc combined with other metadata:</p><ul><li>Lineage is used in our search engine as a parameter on results ranking. We use it to calculate a centrality measure: the more transitive dependencies a data asset has, the more central and probably more important it is. In a similar way, datasets that are accessed more often are ranked higher on our search results.</li><li>In Datadoc we extract SLO information from the dataset definitions and we expose live information about their latency (freshness). This allows us to alert on datasets taking more time to compute than they should. We use lineage to provide insights to the users on the root cause of data delays (e.g., the most upstream late dependency) and we generate what we call SLO-graphs, where we put together all this information on a group of datasets.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mq6SXvIq_3y055QiqYyAMA.png" /><figcaption>Datadoc SLO-graph for our metrology pipeline</figcaption></figure><h3>How we compute the lineage</h3><h4>The basic techniques</h4><p>There are <a href="https://medium.com/alvin-ai/what-is-data-lineage-and-techniques-to-implement-it-4f1939b11327">several techniques</a> that can be used to compute lineage:</p><ul><li><strong>Manual:</strong> The first basic technique consists of manually introducing lineage relationships, typically by the data asset owners or data stewards. This technique can cover anything, but obviously it is very time-consuming and unreliable, as the relationships can quickly become out of date.</li><li><strong>Pattern-based:</strong> With this technique, we are looking for specific patterns in the available metadata about our data assets. This is an automatic technique that can be run over many systems, but it is not accurate in all cases.</li><li><strong>Logs-as-source:</strong> In some cases, we can parse runtime information from the services of our data platform and extract the lineage. For instance, a very common technique consists of parsing the query logs of a query engine and extracting lineage relationships from the queries that were executed to produce new datasets. In the same way, some systems can store events about specific data transformations that can be parsed to extract lineage information.</li><li><strong>Code-as-source:</strong> In this case, we don’t look at the runtime information, but at the source code that specifies the data transformations. Some components can be similar to the previous technique, as we might also need to parse queries, but the scope is different. This can even discover lineage relationships that rarely happen (and thus might not appear on the runtime information). However, accessing all the code-generating data transformations is much more complex as it can be scattered across many projects and repositories and encoded in complex ways. Additionally, it cannot track usages that only happen at runtime.</li><li><strong>Self-contained:</strong> Finally, there are some systems that include built-in lineage capabilities and that expose lineage relationships programmatically (e.g., through an API). Obviously, this is the best option for the services that provide it, as it is fully accurate and can provide additional contextual information. However, we cannot cover all of our data platform with this technique.</li></ul><p>At Criteo, we have used all these techniques. When I arrived at the company 7 years ago, lineage was only in the minds of a handful of data engineers of the core data teams who had to dump their brains into a whiteboard every time there was a data incident to investigate and fix or a complex migration to plan. Since then, we have constructed an automatic and extensive mechanism to extract lineage from our data services. Here we will explain in more detail how we have built it.</p><h4>An overview of our data platform</h4><p>At Criteo, most of our offline data processing happens on our data lake, which consists of a big Hadoop cluster of 3000 machines storing more than 180PB of data. On top of it, we run mainly Spark jobs and Hive queries doing data transformations and orchestrated by two homemade tools, <a href="https://github.com/criteo/cuttle">Cuttle</a> and <a href="https://medium.com/criteo-engineering/scheduling-data-pipelines-at-criteo-part-1-8b257c6c8e55">Bigdataflow</a>. Our ML engine also runs on this cluster retraining all our models regularly.</p><p>Most of the raw data that is ingested comes from Kafka, where a central system writes batches regularly to our data lake. After the transformations, the analytics data is consumed directly by human users with Presto / Trino (ad-hoc queries, Jupyter, etc.), or exported to Vertica, again through a central application that orchestrates the exports. There, users also perform ad-hoc queries, but some clusters are dedicated to serve some user-facing applications or consumed by our Tableau installation. We have developed a system on top of Tableau that takes care of publishing and modifying the reports and refreshing the underlying data.</p><p>Unsurprisingly, there are many other systems that ingest and export the data. For instance, the ML models are pushed to the services that perform the inferences, and some data is pushed to key-value stores to be used during this phase.</p><h4>The basics of our lineage</h4><p>As explained before, most of the ingress and egress of data in our Hadoop cluster goes through some centralized platforms. This has several advantages, but in the case of lineage, it allows us to expose this information on the API of these services (self-contained lineage). In some cases, we can even perform lineage analysis on the code itself (code-as-source) and use it during validation in our CI.</p><p>The most complex part consists of tracking all the data transformations that occur in our Hadoop cluster. For this, we use several layers of lineage.</p><p>For SQL engines such as Hive or Presto/Trino, we leverage their own parser to expose lineage information (we use a variation of <a href="https://atlas.apache.org/#/HookHive">Atlas’ hook for Hive</a>). We have set up some hooks that send all the context about the query execution (including column-level lineage) to a Kafka topic, that is then sent to our metrology pipeline. This is the data with the highest quality, as it shows the reality as understood by the underlying system, and references entities with associated semantics (tables, partitions).</p><p>For other transformations orchestrated by our service BigDataflow, we produce a similar event-based Kafka topic. This allows us to capture column-level information on SparkSQL queries as well. BigDataflow parses all the queries that it orchestrates, which allows it to extract such information. Note that BigDataflow being also a development platform, is <a href="https://medium.com/criteo-engineering/bigdataflow-continuous-delivery-of-data-pipelines-52dd5a8f55e9">able to detect the impact of changes during validation</a>. When there are breaking changes (table / column removal, type changes) it will fail the validation preventing it from being merged. All this is possible as it is able to parse the transformation and extract the lineage from it.</p><p>Then, there are the rest of the things that run on our Hadoop cluster, which are many and diverse. We leverage <a href="https://medium.com/criteo-engineering/serving-growing-user-needs-with-automated-tooling-498978db2941">Garmadon</a>, an event collector service that tracks all interactions with our underlying file system. This allows us to capture the provenance of all data that is written in our data lake. The problem, as we will see later, is that the information that is generated is very low level, as we are just obtaining relationships between applications (e.g., an application_id) and raw paths, which don’t carry meaningful semantic information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWbee6jCezEj3BCVVG2ksA.png" /><figcaption>Overview of the lineage techniques used at Criteo</figcaption></figure><h4>Putting it all together</h4><p>All the techniques described before feed our metrology pipeline, where we put everything together in a form that can be consumed directly by the users (through regular queries) or by Datadoc, our data catalog and data observability service.</p><p>The most complex transformations in this pipeline deal with two issues. First, we need to provide semantic meaning to the raw information that is handled by Garmadon. We perform a series of tasks in order to do that:</p><ul><li>We coalesce applications that belong to the same logical transformation. This allows us to discard intermediate results, which are only temporary, and put together the inputs and outputs of this transformation. We mostly use pattern-based techniques for this. Garmadon also allows us to inject some tags into the applications, that allow us to link the executions to the logical units that are declared in our orchestrators.</li><li>We link together the semantic information already available in the Hive Metastore with the raw paths. If the data is backed by a table, we are able to do the link, bringing back the semantic meaning. Even if the data is generated in many different forms, registering it on our Metastore is a common practice as it activates many functionalities in our data platform. For the data that is not tracked in the Metastore, we use pattern-based techniques to provide this semantical meaning.</li></ul><p>Then, we put together the data coming from our various lineage sources. Note that different sources may report the same transformation, so we need to perform a deduplication. For instance, data written by Hive or Spark will appear both in our hooks and in Garmadon. We are able to detect this and use the information coming from the hook in priority, as the quality is better.</p><p>Using all of these tasks we are able to provide a complete and semantically meaningful lineage, that links inputs and outputs and the applications and executions that consumed and produced them. From there, we perform some other additional transformations to expose the data in forms that are more adapted to specific use cases (e.g. usage analysis for optimization, graph closure for impact analysis, etc.)</p><h4>How do we monitor all that?</h4><p>As with any lineage service, it is very hard to track every single transformation, at least with the highest level of quality. Because of that, we constantly monitor our lineage pipeline and compare it with the metadata of the existing entities (paths, tables, columns, partitions, etc.). Then we can compute what percentage of entities and volume of data can be explained with our lineage. For instance, we are able to track 99.1% of the data stored in our data lake at the dataset level.</p><h3>The future</h3><p>With lineage, the job is never finished. There are always improvements to do and new use cases to track and this is also the case in Criteo. Building our lineage is an iterative process and we choose to focus on the aspects that can bring a higher ROI at a moment in time. Several elements are part of our roadmap:</p><ul><li>Leverage the lineage to automatically group data quality issues.</li><li>More globally, use lineage to help with data incident resolution. This includes (semi-)automating the reparation of impacted datasets.</li><li>Provide richer insights to perform optimizations on the usage of our resources.</li><li>Use lineage to propose the propagation of documentation in our data catalog.</li><li>And, as always, improve the coverage of our system, both by better tracking the systems that are already integrated in the lineage and start tracking other systems that interact with our data lake.</li></ul><p><a href="https://bit.ly/eng-careers-medium">Engineering</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f09fc5c577" width="1" height="1" alt=""><hr><p><a href="https://medium.com/criteo-engineering/how-we-compute-data-lineage-at-criteo-b3f09fc5c577">How we compute data lineage at Criteo</a> was originally published in <a href="https://medium.com/criteo-engineering">Criteo Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>