SQL to CQL: Basic Query Structure

SQL operates as a direct method declaring and selecting data for extraction from a structured set of tables. The process of querying data in SQL is to select/declare the information needed and return as a single structured table.

CQL, by contrast uses a query flow, where individual query steps can be chained together using the | (pipe) symbol in a fashion similar to the Unix shell. Query process and transformation effectively happens from the data source (repository) through to the result set. For example, a typical statement might be:

sql
SELECT field1, field2 FROM table WHERE condition ORDER BY field1;

In LogScale this might look like:

logscale
condition 
| sort(field1)

In LogScale this will produce a table and through the UI you can select the fields to view. To create a specific table:

logscale
condition 
| sort(field1) 
| table([field1, field2])

When migrating SQL queries:

  1. Think in pipelines: Visualize data flowing through transformations rather than declarative statements

  2. Embrace pattern matching: LogScale excels at regex and pattern-based searching

  3. Leverage time-based features: Design queries with time windows in mind

  4. Start simple: Begin with basic filters before adding complexity

  5. Use the query validator: Test and refine queries incrementally

  6. Review query performance: Check query statistics to optimize performance