Skip to main content

filter_conditions.go

Overview - filter_conditions.go

This file provides utility functions for building filter conditions for ClickHouse queries based on a provided filter set. It includes functions for handling various filter operators and data types.

Detailed Documentation

BuildFilterConditions

  • Purpose: Builds a slice of filter conditions for ClickHouse queries based on a filter set.
  • Parameters:
    • fs (*v3.FilterSet): The filter set containing the filter items.
    • skipKey (string): An optional key to skip processing.
  • Returns:
    • []string: A slice of strings representing the filter conditions.
    • error: An error if building the conditions fails.

buildSingleFilterCondition

  • Purpose: Builds a single filter condition for ClickHouse query.
  • Parameters:
    • key (string): The key/column to filter on.
    • op (v3.FilterOperator): The filter operator.
    • fmtVal (string): The formatted value for the filter.
    • isJSONKey (bool): A flag indicating if the key is a JSON key.
  • Returns:
    • string: The built filter condition.
    • error: An error if building the condition fails.

WhichTSTableToUse

  • Purpose: Determines which time-series table to use based on the time range.
  • Parameters:
    • start (int64): The start timestamp in milliseconds.
    • end (int64): The end timestamp in milliseconds.
  • Returns:
    • int64: Adjusted start time.
    • int64: End time.
    • string: The name of the appropriate time-series table.
    • string: The name of the local table.

WhichSampleTableToUse

  • Purpose: Determines which sample table to use based on the time range.
  • Parameters:
    • start (int64): The start timestamp in milliseconds.
    • end (int64): The end timestamp in milliseconds.
  • Returns:
    • string: The name of the appropriate sample table.
    • string: The aggregation function to use.

WhichAttributesTableToUse

  • Purpose: Determines which attributes metadata table to use based on the time range.
  • Parameters:
    • start (int64): The start timestamp in milliseconds.
    • end (int64): The end timestamp in milliseconds.
  • Returns:
    • int64: Adjusted start time.
    • int64: End time.
    • string: The name of the appropriate attributes table.
    • string: The name of the local attributes table.

Code Examples

// Example of building filter conditions
const conditions, err = BuildFilterConditions(filterSet, "someKey");

// Example of determining which table to use
const start, end, tableName, localTableName = WhichTSTableToUse(startTime, endTime);

Include in Getting Started: NO