reporting

package
v0.0.0-...-1d44d98 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReportingStartInputName = "ReportingStart"
	ReportingEndInputName   = "ReportingEnd"
)

Variables

This section is empty.

Functions

func FmtPartitionSpec

func FmtPartitionSpec(partitionColumns []hive.Column, partSpec hive.PartitionSpec) string

func IsInvalidDependencyError

func IsInvalidDependencyError(err error) bool

func IsUninitializedDependencyError

func IsUninitializedDependencyError(err error) bool

func NewReportGenerator

func NewReportGenerator(logger log.FieldLogger, reportResultsRepo prestostore.ReportResultsRepo) *reportGenerator

func PrestoTimestamp

func PrestoTimestamp(input interface{}) (string, error)

PrestoTimestamp is a helper function that returns the Presto timestamp format

func PrometheusMetricPartitionFormat

func PrometheusMetricPartitionFormat(input interface{}) (string, error)

PrometheusMetricPartitionFormat is a helper function that returns the Prometheus timestamp partition format

func RenderQuery

func RenderQuery(ctx *ReportQueryTemplateContext, tmplCtx TemplateContext) (string, error)

RenderQuery creates a new query template by calling the ctx parameter's method, newQueryTemplate, and checks if the returned error is nil. If nil, return an empty string and the error, else return the function call to renderTemplate, passing in the new query template and tmplCtx parameter.

func TimestampFormat

func TimestampFormat(input interface{}, format string) (string, error)

TimestampFormat checks the type of the input interface parameter and returns that parameter in the form specified by the format string parameter, or an error if it's not able to be converted.

Types

type DependencyResolutionResult

type DependencyResolutionResult struct {
	Dependencies *ReportQueryDependencies
	InputValues  map[string]interface{}
}

type DependencyResolver

type DependencyResolver struct {
	// contains filtered or unexported fields
}

func NewDependencyResolver

func NewDependencyResolver(
	queryGetter ReportQueryGetter,
	dataSourceGetter ReportDataSourceGetter,
	reportGetter ReportGetter) *DependencyResolver

func (*DependencyResolver) ResolveDependencies

func (resolver *DependencyResolver) ResolveDependencies(namespace string, inputDefs []metering.ReportQueryInputDefinition, inputVals []metering.ReportQueryInputValue) (*DependencyResolutionResult, error)

type HiveDatabaseManager

type HiveDatabaseManager interface {
	CreateDatabase(params hive.DatabaseParameters) error
	DropDatabase(dbName string, ignoreNotExists, cascade bool) error
}

type HiveManager

type HiveManager struct {
	// contains filtered or unexported fields
}

func NewHiveManager

func NewHiveManager(execer db.Execer) *HiveManager

func (*HiveManager) AddPartition

func (m *HiveManager) AddPartition(dbName, tableName string, partitionColumns []hive.Column, partition hive.TablePartition) error

func (*HiveManager) CreateDatabase

func (m *HiveManager) CreateDatabase(params hive.DatabaseParameters) error

func (*HiveManager) CreateTable

func (m *HiveManager) CreateTable(params hive.TableParameters, ignoreExists bool) error

func (*HiveManager) DropDatabase

func (m *HiveManager) DropDatabase(dbName string, ignoreNotExists, cascade bool) error

func (*HiveManager) DropPartition

func (m *HiveManager) DropPartition(dbName, tableName string, partitionColumns []hive.Column, partition hive.TablePartition) error

func (*HiveManager) DropTable

func (m *HiveManager) DropTable(dbName, tableName string, ignoreNotExists bool) error

type HivePartitionManager

type HivePartitionManager interface {
	AddPartition(dbName, tableName string, partitionColumns []hive.Column, partition hive.TablePartition) error
	DropPartition(dbName, tableName string, partitionColumns []hive.Column, partition hive.TablePartition) error
}

type HiveTableManager

type HiveTableManager interface {
	CreateTable(params hive.TableParameters, ignoreExists bool) error
	DropTable(dbName, tableName string, ignoreNotExists bool) error
}

type PrestoHealthChecker

type PrestoHealthChecker struct {
	// contains filtered or unexported fields
}

func NewPrestoHealthChecker

func NewPrestoHealthChecker(logger logrus.FieldLogger, queryer db.Queryer, tableManager HiveTableManager, databaseName, tableName string) *PrestoHealthChecker

func (*PrestoHealthChecker) TestReadFromPresto

func (checker *PrestoHealthChecker) TestReadFromPresto() bool

func (*PrestoHealthChecker) TestReadFromPrestoSingleFlight

func (checker *PrestoHealthChecker) TestReadFromPrestoSingleFlight() bool

func (*PrestoHealthChecker) TestWriteToPresto

func (checker *PrestoHealthChecker) TestWriteToPresto() bool

func (*PrestoHealthChecker) TestWriteToPrestoSingleFlight

func (checker *PrestoHealthChecker) TestWriteToPrestoSingleFlight() bool

type PrestoTableManager

type PrestoTableManager interface {
	CreateTable(catalog, schema, tableName string, columns []presto.Column, comment string, properties map[string]string, ignoreExists bool) error
	CreateTableAs(catalog, schema, tableName string, columns []presto.Column, comment string, properties map[string]string, ignoreExists bool, query string) error
	DropTable(catalog, schema, tableName string, ignoreNotExists bool) error
	QueryMetadata(catalog, schema, tableName string) ([]presto.Column, error)

	CreateView(catalog, schema, viewName, query string) error
	DropView(catalog, schema, viewName string, ignoreNotExists bool) error
}

type PrestoTableManagerImpl

type PrestoTableManagerImpl struct {
	// contains filtered or unexported fields
}

func NewPrestoTableManager

func NewPrestoTableManager(queryer db.Queryer) *PrestoTableManagerImpl

func (*PrestoTableManagerImpl) CreateTable

func (c *PrestoTableManagerImpl) CreateTable(catalog, schema, tableName string, columns []presto.Column, comment string, properties map[string]string, ignoreExists bool) error

func (*PrestoTableManagerImpl) CreateTableAs

func (c *PrestoTableManagerImpl) CreateTableAs(catalog, schema, tableName string, columns []presto.Column, comment string, properties map[string]string, ignoreExists bool, query string) error

func (*PrestoTableManagerImpl) CreateView

func (c *PrestoTableManagerImpl) CreateView(catalog, schema, viewName, query string) error

func (*PrestoTableManagerImpl) DropTable

func (c *PrestoTableManagerImpl) DropTable(catalog, schema, tableName string, ignoreNotExists bool) error

func (*PrestoTableManagerImpl) DropView

func (c *PrestoTableManagerImpl) DropView(catalog, schema, viewName string, ignoreNotExists bool) error

func (*PrestoTableManagerImpl) QueryMetadata

func (c *PrestoTableManagerImpl) QueryMetadata(catalog, schema, tableName string) ([]presto.Column, error)

type ReportDataSourceGetter

type ReportDataSourceGetter interface {
	GetReportDataSource(namespace, name string) (*metering.ReportDataSource, error)
}

type ReportDataSourceGetterFunc

type ReportDataSourceGetterFunc func(string, string) (*metering.ReportDataSource, error)

func (ReportDataSourceGetterFunc) GetReportDataSource

func (f ReportDataSourceGetterFunc) GetReportDataSource(namespace, name string) (*metering.ReportDataSource, error)

type ReportGenerator

type ReportGenerator interface {
	GenerateReport(tableName, query string, deleteExistingData bool) error
}

type ReportGetter

type ReportGetter interface {
	GetReport(namespace, name string) (*metering.Report, error)
}

func NewReportClientGetter

func NewReportClientGetter(getter meteringClient.ReportsGetter) ReportGetter

func NewReportListerGetter

func NewReportListerGetter(lister meteringListers.ReportLister) ReportGetter

type ReportGetterFunc

type ReportGetterFunc func(string, string) (*metering.Report, error)

func (ReportGetterFunc) GetReport

func (f ReportGetterFunc) GetReport(namespace, name string) (*metering.Report, error)

type ReportQueryDependencies

type ReportQueryDependencies struct {
	ReportQueries     []*metering.ReportQuery
	ReportDataSources []*metering.ReportDataSource
	Reports           []*metering.Report
}

func GetAndValidateQueryDependencies

func GetAndValidateQueryDependencies(
	queryGetter ReportQueryGetter,
	dataSourceGetter ReportDataSourceGetter,
	reportGetter ReportGetter,
	query *metering.ReportQuery,
	inputVals []metering.ReportQueryInputValue,
	handler *UninitialiedDependendenciesHandler,
) (*ReportQueryDependencies, error)

func GetQueryDependencies

func GetQueryDependencies(
	queryGetter ReportQueryGetter,
	dataSourceGetter ReportDataSourceGetter,
	reportGetter ReportGetter,
	query *metering.ReportQuery,
	inputVals []metering.ReportQueryInputValue,
) (*ReportQueryDependencies, error)

type ReportQueryGetter

type ReportQueryGetter interface {
	GetReportQuery(namespace, name string) (*metering.ReportQuery, error)
}

type ReportQueryGetterFunc

type ReportQueryGetterFunc func(string, string) (*metering.ReportQuery, error)

func (ReportQueryGetterFunc) GetReportQuery

func (f ReportQueryGetterFunc) GetReportQuery(namespace, name string) (*metering.ReportQuery, error)

type ReportQueryTemplateContext

type ReportQueryTemplateContext struct {
	Namespace      string
	Query          string
	RequiredInputs []string

	Reports           []*metering.Report
	ReportQueries     []*metering.ReportQuery
	ReportDataSources []*metering.ReportDataSource
	PrestoTables      []*metering.PrestoTable
}

ReportQueryTemplateContext is used to hold all information about a ReportQuery that will be needed when rendering the templating inside of a ReportQuery's query field.

type ReportTemplateInfo

type ReportTemplateInfo struct {
	ReportingStart *time.Time
	ReportingEnd   *time.Time
	Inputs         map[string]interface{}
}

ReportTemplateInfo contains the variables for the Reprot being executed with this template.

type TemplateContext

type TemplateContext struct {
	Report ReportTemplateInfo
}

TemplateContext is the context passed to each template and contains variables related to the Report and ReportQuery such as inputs and dependencies on other resources.

type UninitialiedDependendenciesHandler

type UninitialiedDependendenciesHandler struct {
	HandleUninitializedReportDataSource func(*metering.ReportDataSource)
}

Jump to

Keyboard shortcuts

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