Skip to main content

sub_query.go

sub_query.go - Overview

  1. Overview This file provides helper functions for creating sub-queries used in metric data retrieval, including functions to determine which table to use based on the time range, and to prepare time series filter queries.

  2. Detailed Documentation

    whichTSTableToUse(start, end int64, mq *v3.BuilderQuery) (int64, int64, string)

    • Purpose: Determines which time series table to use based on the given start and end times and the builder query configuration.
    • Parameters:
      • start: int64 - Start timestamp in milliseconds.
      • end: int64 - End timestamp in milliseconds.
      • mq: *v3.BuilderQuery - Builder query object containing query parameters, including potential table hints.
    • Returns:
      • int64: Adjusted start timestamp (aligned to table's time granularity).
      • int64: End timestamp (unmodified).
      • string: The name of the time series table to use.

    WhichSamplesTableToUse(start, end int64, mq *v3.BuilderQuery) string

    • Purpose: Determines which samples table to use based on the time range and query parameters, considering pre-aggregation settings.
    • Parameters:
      • start: int64 - Start timestamp in milliseconds.
      • end: int64 - End timestamp in milliseconds.
      • mq: *v3.BuilderQuery - Builder query object containing query parameters, including aggregation type and table hints.
    • Returns:
      • string: The name of the samples table to use.

    AggregationColumnForSamplesTable(start, end int64, mq *v3.BuilderQuery) string

    • Purpose: Determines the appropriate aggregation column to use in the query based on the temporality and table being queried.
    • Parameters:
      • start: int64 - Start timestamp in milliseconds.
      • end: int64 - End timestamp in milliseconds.
      • mq: *v3.BuilderQuery - Builder query object containing query parameters, including temporality and aggregation settings.
    • Returns:
      • string: The name of the aggregation column to use in the query.

    PrepareTimeseriesFilterQuery(start, end int64, mq *v3.BuilderQuery) (string, error)

    • Purpose: Builds a sub-query for filtering time series data based on the search criteria provided in the builder query.
    • Parameters:
      • start: int64 - Start timestamp in milliseconds.
      • end: int64 - End timestamp in milliseconds.
      • mq: *v3.BuilderQuery - Builder query object containing query parameters, including filters and group by settings.
    • Returns:
      • string: The generated sub-query string for filtering time series data.
      • error: An error object if any issue occurs during query preparation.

    PrepareTimeseriesFilterQueryV3(start, end int64, mq *v3.BuilderQuery) (string, error)

    • Purpose: Builds a sub-query for filtering time series data (V3 version), based on the search criteria provided in the builder query.
    • Parameters:
      • start: int64 - Start timestamp in milliseconds.
      • end: int64 - End timestamp in milliseconds.
      • mq: *v3.BuilderQuery - Builder query object containing query parameters, including filters and group by settings.
    • Returns:
      • string: The generated sub-query string for filtering time series data.
      • error: An error object if any issue occurs during query preparation.
  3. Code Examples

    None

  4. Clarity and Accuracy

    All documented functions have clear descriptions and parameter/return value explanations.

  5. Markdown & MDX Perfection

    The documentation uses proper markdown syntax for headings, lists, and code blocks.

  6. Edge Cases To Avoid Breaking MDX

    • No unescaped special characters.
    • No broken links or images.
    • No raw HTML tags.
    • No HTML comments.
    • No tables.
    • Lists are properly indented.
    • Code blocks and headings are properly closed.
  7. Getting Started Relevance Include in Getting Started: NO