---
title: "Real-Time Data Classification with Generated Column"
url: https://daily.dev/posts/real-time-data-classification-with-generated-column-wh0q0cd09
source_url: https://cratedb.com/blog/real-time-data-classification-with-generated-column
type: article
source: "CrateDB"
published: 2026-08-24T14:56:50.247Z
updated: 2026-08-24T14:57:13.037Z
tags: ["sql", "cratedb"]
reading_time: 6
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Real-Time Data Classification with Generated Column

**[CrateDB](https://daily.dev/sources/cratedb)** · 6 min read · 0 upvotes · 0 comments

## Summary

CrateDB's generated columns let you classify and index streaming data at insert time rather than in a separate cleanup pass. A worked example models baggage-handling events at Heathrow Terminal 5 using five generated columns: an oversize boolean flag from a CASE expression, a reported_late flag comparing event timestamps to catch upstream lag, a geo_location field converting raw lat/long into a GEO_POINT, an in_t5 boolean from a within() polygon check, and an event_week timestamp used to auto-partition the table by week. Because these values are computed once on write and stored/indexed like any other column, later queries become cheap boolean filters instead of repeated computations, and old data can be dropped by removing entire weekly partitions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://cratedb.com/blog/real-time-data-classification-with-generated-column>

## Questions this post answers

### How can I flag oversize bags or records automatically as they are inserted into a database instead of computing it at query time?

Use a generated column with a CASE expression that evaluates the business rule on every insert. For example, a CrateDB BOOLEAN column defined as GENERATED ALWAYS AS a CASE statement over length, width, and height columns computes an oversize flag automatically, so any application inserting rows gets the same consistent result without repeating logic in every query.

_Explore how developers apply generated columns for consistent data rules on daily.dev._

### How do I automatically partition a time-series table by week without the application knowing about partitions?

Create a generated column that truncates the event timestamp to the start of its week using date_trunc('week', conveyer_timestamp), and partition the table by that column. Rows then route themselves into weekly partitions automatically, and dropping data older than a retention window becomes a matter of dropping whole partitions instead of deleting millions of rows individually.

_Developers designing time-series retention strategies can track database techniques like this on daily.dev._

### How do I convert raw latitude and longitude fields into a usable geo point for mapping and geo queries in CrateDB?

Define a generated column typed as GEO_POINT that is computed from the raw lat and long fields, for example GENERATED ALWAYS AS [reported_location['long'], reported_location['lat']]. This produces a proper GEO_POINT value stored and indexed on every insert, enabling CrateDB's geo functions and direct plotting on tools like Grafana without any query-time conversion.

_Anyone building geospatial dashboards can follow database and mapping patterns like this on daily.dev._

## Similar posts on daily.dev

- [What Is a Columnar Database? Understanding the Power Behind Real-Time Analytics](https://daily.dev/posts/what-is-a-columnar-database-understanding-the-power-behind-real-time-analytics-ddxxul0dj) · CrateDB · 0 upvotes · 0 comments
- [Inside CrateDB: How Storage Optimization Powers Real-Time Analytics at Scale](https://daily.dev/posts/inside-cratedb-how-storage-optimization-powers-real-time-analytics-at-scale-3iozebt7s) · CrateDB · 0 upvotes · 0 comments
- [Inside CrateDB’s Real-Time Query Engine: Aggregations, Ad-Hoc Queries, Hybrid Search, and AI](https://daily.dev/posts/inside-cratedb-s-real-time-query-engine-aggregations-ad-hoc-queries-hybrid-search-and-ai-sl7jvqmbr) · CrateDB · 1 upvotes · 0 comments

---

Tags: [#sql](https://daily.dev/tags/sql), [#cratedb](https://daily.dev/tags/cratedb)

[View this post on daily.dev](https://daily.dev/posts/real-time-data-classification-with-generated-column-wh0q0cd09)
