Documentation
¶
Overview ¶
queryClient.go
server.go
Index ¶
- func GetRootDir() string
- func JsonFormatter(data []map[string]any, w http.ResponseWriter) error
- func NDJsonFormatter(data []map[string]any, w http.ResponseWriter) error
- func ProcessResultsForJSON(results []map[string]interface{}) []map[string]interface{}
- func StartFlightSQLServer(port int, queryClient *QueryClient) error
- func StopFlightSQLServer()
- type ErrorResponse
- type FlightSQLServer
- func (s *FlightSQLServer) DoAction(action *flight.Action, stream flight.FlightService_DoActionServer) error
- func (s *FlightSQLServer) DoExchange(stream flight.FlightService_DoExchangeServer) error
- func (s *FlightSQLServer) DoGet(ticket *flight.Ticket, stream flight.FlightService_DoGetServer) error
- func (s *FlightSQLServer) DoPut(stream flight.FlightService_DoPutServer) error
- func (s *FlightSQLServer) GetFlightInfo(ctx context.Context, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
- func (s *FlightSQLServer) GetFlightInfoStatement(ctx context.Context, cmd *flightsql.StatementQuery, ...) (*flight.FlightInfo, error)
- func (s *FlightSQLServer) GetSchema(ctx context.Context, desc *flight.FlightDescriptor) (*flight.SchemaResult, error)
- func (s *FlightSQLServer) Handshake(stream flight.FlightService_HandshakeServer) error
- func (s *FlightSQLServer) ListActions(request *flight.Empty, stream flight.FlightService_ListActionsServer) error
- func (s *FlightSQLServer) ListFlights(criteria *flight.Criteria, stream flight.FlightService_ListFlightsServer) error
- func (s *FlightSQLServer) PollFlightInfo(ctx context.Context, desc *flight.FlightDescriptor) (*flight.PollInfo, error)
- type MetadataFile
- type ParquetFile
- type ParsedQuery
- type QueryClient
- func (q *QueryClient) Close() error
- func (q *QueryClient) FindRelevantFiles(ctx context.Context, dbName, measurement string, timeRange TimeRange) ([]*metadata.IndexEntry, error)
- func (q *QueryClient) Initialize() error
- func (q *QueryClient) ParseQuery(sql, dbName string) (*ParsedQuery, error)
- func (c *QueryClient) Query(ctx context.Context, query, dbName string) ([]map[string]interface{}, error)
- func (c *QueryClient) QueryArrow(ctx context.Context, query string) (array.RecordReader, *arrow.Schema, error)
- type QueryRequest
- type QueryResponse
- type Server
- type TimeRange
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 ¶
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 ¶
func (s *FlightSQLServer) DoAction(action *flight.Action, stream flight.FlightService_DoActionServer) error
DoAction implements the FlightService interface
func (*FlightSQLServer) DoExchange ¶
func (s *FlightSQLServer) DoExchange(stream flight.FlightService_DoExchangeServer) error
DoExchange implements the FlightService interface
func (*FlightSQLServer) DoGet ¶
func (s *FlightSQLServer) DoGet(ticket *flight.Ticket, stream flight.FlightService_DoGetServer) error
DoGet implements the FlightSQL server interface for retrieving data
func (*FlightSQLServer) DoPut ¶
func (s *FlightSQLServer) DoPut(stream flight.FlightService_DoPutServer) error
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 ¶
func (s *FlightSQLServer) GetSchema(ctx context.Context, desc *flight.FlightDescriptor) (*flight.SchemaResult, error)
GetSchema implements the FlightService interface
func (*FlightSQLServer) Handshake ¶
func (s *FlightSQLServer) Handshake(stream flight.FlightService_HandshakeServer) error
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) 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 ¶
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 (*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