Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSQLComment ¶
AppendSQLComment appends a query context SQL comment to the given SQL string if query context is present in the context. Returns the original SQL unchanged if no query context is set.
func WithQueryContext ¶
func WithQueryContext(ctx context.Context, qc QueryContext) context.Context
WithQueryContext attaches query context metadata to a Go context.
Types ¶
type QueryContext ¶
QueryContext holds key-value metadata to attach to database queries. It is used to track query provenance (e.g., originating from SYNQ, associated monitor or model) across all supported data warehouses.
func GetQueryContext ¶
func GetQueryContext(ctx context.Context) QueryContext
GetQueryContext retrieves query context from a Go context. Returns nil if not set.
func (QueryContext) AsBigQueryLabels ¶
func (qc QueryContext) AsBigQueryLabels() map[string]string
AsBigQueryLabels converts the query context to BigQuery-compatible job labels. Keys are lowercased and sanitized (non-alphanumeric/underscore/dash replaced with underscore). Keys and values are truncated to 63 characters.
func (QueryContext) FormatAsJSON ¶
func (qc QueryContext) FormatAsJSON() string
FormatAsJSON returns the query context as a JSON string.
func (QueryContext) FormatAsSQLComment ¶
func (qc QueryContext) FormatAsSQLComment() string
FormatAsSQLComment returns the query context as a SQL block comment suitable for appending to a query string: /* {"key":"value"} */