querier

package
v0.0.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

queryClient.go

server.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRootDir added in v0.0.6

func GetRootDir() string

func JsonFormatter added in v0.0.9

func JsonFormatter(data []map[string]any, w http.ResponseWriter) error

func NDJsonFormatter added in v0.0.9

func NDJsonFormatter(data []map[string]any, w http.ResponseWriter) error

func ProcessResultsForJSON

func ProcessResultsForJSON(results []map[string]interface{}) []map[string]interface{}

ProcessResultsForJSON prepares results for JSON serialization

func StartFlightSQLServer

func StartFlightSQLServer(port int, queryClient *QueryClient) error

StartFlightSQLServer starts the FlightSQL server

func StopFlightSQLServer added in v0.0.13

func StopFlightSQLServer()

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an API error response

type FlightSQLServer

type FlightSQLServer struct {
	flightgen.UnimplementedFlightServiceServer
	flightsql.BaseServer
	// contains filtered or unexported fields
}

FlightSQLServer implements the FlightSQL server interface

func NewFlightSQLServer

func NewFlightSQLServer(queryClient *QueryClient) *FlightSQLServer

NewFlightSQLServer creates a new FlightSQL server instance

func (*FlightSQLServer) DoAction

DoAction implements the FlightService interface

func (*FlightSQLServer) DoExchange

DoExchange implements the FlightService interface

func (*FlightSQLServer) DoGet

DoGet implements the FlightSQL server interface for retrieving data

func (*FlightSQLServer) DoPut

DoPut implements the FlightService interface

func (*FlightSQLServer) GetFlightInfo

func (s *FlightSQLServer) GetFlightInfo(ctx context.Context, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)

GetFlightInfo implements the FlightService interface

func (*FlightSQLServer) GetFlightInfoStatement

func (s *FlightSQLServer) GetFlightInfoStatement(ctx context.Context, cmd *flightsql.StatementQuery, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)

GetFlightInfoStatement implements the FlightSQL server interface for executing SQL statements

func (*FlightSQLServer) GetSchema

GetSchema implements the FlightService interface

func (*FlightSQLServer) Handshake

Handshake implements the FlightService interface

func (*FlightSQLServer) ListActions

func (s *FlightSQLServer) ListActions(request *flight.Empty, stream flight.FlightService_ListActionsServer) error

ListActions implements the FlightService interface

func (*FlightSQLServer) ListFlights

func (s *FlightSQLServer) ListFlights(criteria *flight.Criteria, stream flight.FlightService_ListFlightsServer) error

ListFlights implements the FlightService interface

func (*FlightSQLServer) PollFlightInfo

func (s *FlightSQLServer) PollFlightInfo(ctx context.Context, desc *flight.FlightDescriptor) (*flight.PollInfo, error)

PollFlightInfo implements the FlightService interface

type MetadataFile

type MetadataFile struct {
	Type             string        `json:"type"`
	ParquetSizeBytes int           `json:"parquet_size_bytes"`
	RowCount         int           `json:"row_count"`
	MinTime          int64         `json:"min_time"`
	MaxTime          int64         `json:"max_time"`
	Files            []ParquetFile `json:"files"`
}

MetadataFile represents a metadata.json file structure

type ParquetFile

type ParquetFile struct {
	Path      string `json:"path"`
	SizeBytes int    `json:"size_bytes"`
	RowCount  int    `json:"row_count"`
	MinTime   int64  `json:"min_time"`
	MaxTime   int64  `json:"max_time"`
}

ParquetFile represents a single parquet file entry in metadata

type ParsedQuery

type ParsedQuery struct {
	Columns         string
	DbName          string
	Measurement     string
	TimeRange       TimeRange
	WhereConditions string
	OrderBy         string
	GroupBy         string
	Having          string
	Limit           int
}

ParsedQuery contains the parsed components of a SQL query

type QueryClient

type QueryClient struct {
	DataDir          string
	DB               *sql.DB
	DefaultTimeRange int64 // 10 minutes in nanoseconds
	// contains filtered or unexported fields
}

QueryClient handles parsing SQL and querying parquet files

func NewQueryClient

func NewQueryClient(dataDir string) *QueryClient

NewQueryClient creates a new QueryClient

func (*QueryClient) Close

func (q *QueryClient) Close() error

Close releases resources

func (*QueryClient) FindRelevantFiles

func (q *QueryClient) FindRelevantFiles(ctx context.Context, dbName, measurement string,
	timeRange TimeRange) ([]*metadata.IndexEntry, error)

Find relevant parquet files based on time range

func (*QueryClient) Initialize

func (q *QueryClient) Initialize() error

Initialize sets up the DuckDB connection

func (*QueryClient) ParseQuery

func (q *QueryClient) ParseQuery(sql, dbName string) (*ParsedQuery, error)

Parse SQL query to extract components

func (*QueryClient) Query

func (c *QueryClient) Query(ctx context.Context, query, dbName string) ([]map[string]interface{}, error)

Query executes a query against the database

func (*QueryClient) QueryArrow added in v0.0.27

func (c *QueryClient) QueryArrow(ctx context.Context, query string) (array.RecordReader, *arrow.Schema, error)

QueryArrow executes a query against DuckDB and returns an Arrow RecordReader and schema

type QueryRequest

type QueryRequest struct {
	Query string `json:"query"`
	DB    string `json:"db,omitempty"`
}

QueryRequest represents a query API request

type QueryResponse

type QueryResponse struct {
	Results []map[string]interface{} `json:"results"`
}

QueryResponse represents a query API response

type Server

type Server struct {
	QueryClient *QueryClient
	DisableUI   bool
	UIFS        afero.Fs
}

Server represents the API server

func NewServer

func NewServer(dataDir string) (*Server, error)

NewServer creates a new server instance

func (*Server) Close

func (s *Server) Close() error

Close the server and release resources

func (*Server) HandleHealth

func (s *Server) HandleHealth(w http.ResponseWriter, r *http.Request)

Health check endpoint

func (*Server) HandleQuery

func (s *Server) HandleQuery(w http.ResponseWriter, r *http.Request)

HandleQuery Handles the /query endpoint

func (*Server) HandleUI

func (s *Server) HandleUI(w http.ResponseWriter, r *http.Request)

HandleUI serves the main UI page

type TimeRange

type TimeRange struct {
	Start         *int64
	End           *int64
	TimeCondition string
}

TimeRange represents a query time range

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL