chore(query): remove usage of query/id package
It was effectively a copied and pasted platform.ID, so change it to a type alias. Once our known references to the query/id package are updated to platform.ID, we'll delete the package.pull/10616/head
parent
fad9b30705
commit
c74bcd11b4
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/influxdata/platform/query/functions"
|
||||
"github.com/influxdata/platform/query/functions/storage"
|
||||
"github.com/influxdata/platform/query/functions/storage/pb"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -171,12 +170,12 @@ type wrapController struct {
|
|||
}
|
||||
|
||||
func (c wrapController) Query(ctx context.Context, orgID platform.ID, query *query.Spec) (query.Query, error) {
|
||||
q, err := c.Controller.Query(ctx, id.ID(orgID), query)
|
||||
q, err := c.Controller.Query(ctx, orgID, query)
|
||||
return q, err
|
||||
}
|
||||
|
||||
func (c wrapController) QueryWithCompile(ctx context.Context, orgID platform.ID, query string) (query.Query, error) {
|
||||
q, err := c.Controller.QueryWithCompile(ctx, id.ID(orgID), query)
|
||||
q, err := c.Controller.QueryWithCompile(ctx, orgID, query)
|
||||
return q, err
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ type bucketLookup struct {
|
|||
BucketService platform.BucketService
|
||||
}
|
||||
|
||||
func (b bucketLookup) Lookup(orgID id.ID, name string) (id.ID, bool) {
|
||||
func (b bucketLookup) Lookup(orgID platform.ID, name string) (platform.ID, bool) {
|
||||
oid := platform.ID(orgID)
|
||||
filter := platform.BucketFilter{
|
||||
OrganizationID: &oid,
|
||||
|
@ -194,7 +193,7 @@ func (b bucketLookup) Lookup(orgID id.ID, name string) (id.ID, bool) {
|
|||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return id.ID(bucket.ID), true
|
||||
return bucket.ID, true
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/influxdata/platform/query/functions"
|
||||
"github.com/influxdata/platform/query/functions/storage"
|
||||
"github.com/influxdata/platform/query/functions/storage/pb"
|
||||
qid "github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/repl"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -131,8 +130,8 @@ func orgService(addr, token string) (platform.OrganizationService, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func orgID(org string) (qid.ID, error) {
|
||||
var oid qid.ID
|
||||
func orgID(org string) (platform.ID, error) {
|
||||
var oid platform.ID
|
||||
err := oid.DecodeFromString(org)
|
||||
return oid, err
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/influxdata/platform/query/control"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/functions/storage"
|
||||
qid "github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/repl"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -85,7 +84,7 @@ func replF(cmd *cobra.Command, args []string) {
|
|||
r.Run()
|
||||
}
|
||||
|
||||
func getFluxREPL(storageHosts storage.Reader, buckets platform.BucketService, orgs platform.OrganizationService, org qid.ID, verbose bool) (*repl.REPL, error) {
|
||||
func getFluxREPL(storageHosts storage.Reader, buckets platform.BucketService, orgs platform.OrganizationService, org platform.ID, verbose bool) (*repl.REPL, error) {
|
||||
conf := control.Config{
|
||||
ExecutorDependencies: make(execute.Dependencies),
|
||||
ConcurrencyQuota: runtime.NumCPU() * 2,
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/plan"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -67,7 +67,7 @@ func New(c Config) *Controller {
|
|||
// QueryWithCompile submits a query for execution returning immediately.
|
||||
// The query will first be compiled before submitting for execution.
|
||||
// Done must be called on any returned Query objects.
|
||||
func (c *Controller) QueryWithCompile(ctx context.Context, orgID id.ID, queryStr string) (*Query, error) {
|
||||
func (c *Controller) QueryWithCompile(ctx context.Context, orgID platform.ID, queryStr string) (*Query, error) {
|
||||
q := c.createQuery(ctx, orgID)
|
||||
err := c.compileQuery(q, queryStr)
|
||||
if err != nil {
|
||||
|
@ -80,14 +80,14 @@ func (c *Controller) QueryWithCompile(ctx context.Context, orgID id.ID, queryStr
|
|||
// Query submits a query for execution returning immediately.
|
||||
// The spec must not be modified while the query is still active.
|
||||
// Done must be called on any returned Query objects.
|
||||
func (c *Controller) Query(ctx context.Context, orgID id.ID, qSpec *query.Spec) (*Query, error) {
|
||||
func (c *Controller) Query(ctx context.Context, orgID platform.ID, qSpec *query.Spec) (*Query, error) {
|
||||
q := c.createQuery(ctx, orgID)
|
||||
q.spec = *qSpec
|
||||
err := c.enqueueQuery(q)
|
||||
return q, err
|
||||
}
|
||||
|
||||
func (c *Controller) createQuery(ctx context.Context, orgID id.ID) *Query {
|
||||
func (c *Controller) createQuery(ctx context.Context, orgID platform.ID) *Query {
|
||||
id := c.nextID()
|
||||
cctx, cancel := context.WithCancel(ctx)
|
||||
ready := make(chan map[string]query.Result, 1)
|
||||
|
@ -265,7 +265,7 @@ func (c *Controller) free(q *Query) {
|
|||
type Query struct {
|
||||
id QueryID
|
||||
|
||||
orgID id.ID
|
||||
orgID platform.ID
|
||||
|
||||
labelValues []string
|
||||
|
||||
|
@ -306,7 +306,7 @@ func (q *Query) ID() QueryID {
|
|||
return q.id
|
||||
}
|
||||
|
||||
func (q *Query) OrganizationID() id.ID {
|
||||
func (q *Query) OrganizationID() platform.ID {
|
||||
return q.orgID
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
)
|
||||
|
||||
// FromBucketService wraps an platform.BucketService in the BucketLookup interface.
|
||||
|
@ -20,7 +19,7 @@ type BucketLookup struct {
|
|||
}
|
||||
|
||||
// Lookup returns the bucket id and its existence given an org id and bucket name.
|
||||
func (b *BucketLookup) Lookup(orgID id.ID, name string) (id.ID, bool) {
|
||||
func (b *BucketLookup) Lookup(orgID platform.ID, name string) (platform.ID, bool) {
|
||||
oid := platform.ID(orgID)
|
||||
filter := platform.BucketFilter{
|
||||
OrganizationID: &oid,
|
||||
|
@ -30,7 +29,7 @@ func (b *BucketLookup) Lookup(orgID id.ID, name string) (id.ID, bool) {
|
|||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return id.ID(bucket.ID), true
|
||||
return bucket.ID, true
|
||||
}
|
||||
|
||||
// FromOrganizationService wraps a platform.OrganizationService in the OrganizationLookup interface.
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"fmt"
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/plan"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Executor interface {
|
||||
Execute(ctx context.Context, orgID id.ID, p *plan.PlanSpec) (map[string]query.Result, error)
|
||||
Execute(ctx context.Context, orgID platform.ID, p *plan.PlanSpec) (map[string]query.Result, error)
|
||||
}
|
||||
|
||||
type executor struct {
|
||||
|
@ -30,7 +30,7 @@ type executionState struct {
|
|||
p *plan.PlanSpec
|
||||
deps Dependencies
|
||||
|
||||
orgID id.ID
|
||||
orgID platform.ID
|
||||
|
||||
alloc *Allocator
|
||||
|
||||
|
@ -46,7 +46,7 @@ type executionState struct {
|
|||
dispatcher *poolDispatcher
|
||||
}
|
||||
|
||||
func (e *executor) Execute(ctx context.Context, orgID id.ID, p *plan.PlanSpec) (map[string]query.Result, error) {
|
||||
func (e *executor) Execute(ctx context.Context, orgID platform.ID, p *plan.PlanSpec) (map[string]query.Result, error) {
|
||||
es, err := e.createExecutionState(ctx, orgID, p)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to initialize execute state")
|
||||
|
@ -62,7 +62,7 @@ func validatePlan(p *plan.PlanSpec) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *executor) createExecutionState(ctx context.Context, orgID id.ID, p *plan.PlanSpec) (*executionState, error) {
|
||||
func (e *executor) createExecutionState(ctx context.Context, orgID platform.ID, p *plan.PlanSpec) (*executionState, error) {
|
||||
if err := validatePlan(p); err != nil {
|
||||
return nil, errors.Wrap(err, "invalid plan")
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ type executionContext struct {
|
|||
}
|
||||
|
||||
// Satisfy the ExecutionContext interface
|
||||
func (ec executionContext) OrganizationID() id.ID {
|
||||
func (ec executionContext) OrganizationID() platform.ID {
|
||||
return ec.es.orgID
|
||||
}
|
||||
|
||||
|
|
|
@ -7,20 +7,20 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/ast"
|
||||
_ "github.com/influxdata/platform/query/builtin"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/execute/executetest"
|
||||
"github.com/influxdata/platform/query/functions"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/plan"
|
||||
"github.com/influxdata/platform/query/semantic"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
var epoch = time.Unix(0, 0)
|
||||
var orgID id.ID
|
||||
var orgID platform.ID
|
||||
|
||||
func init() {
|
||||
orgID.DecodeFromString("aaaa")
|
||||
|
|
|
@ -3,10 +3,10 @@ package functions
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/functions/storage"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/interpreter"
|
||||
"github.com/influxdata/platform/query/plan"
|
||||
"github.com/influxdata/platform/query/semantic"
|
||||
|
@ -189,7 +189,7 @@ func createFromSource(prSpec plan.ProcedureSpec, dsid execute.DatasetID, a execu
|
|||
deps := a.Dependencies()[FromKind].(storage.Dependencies)
|
||||
orgID := a.OrganizationID()
|
||||
|
||||
var bucketID id.ID
|
||||
var bucketID platform.ID
|
||||
if spec.Database == "" {
|
||||
b, ok := deps.BucketLookup.Lookup(orgID, spec.Bucket)
|
||||
if !ok {
|
||||
|
@ -197,7 +197,7 @@ func createFromSource(prSpec plan.ProcedureSpec, dsid execute.DatasetID, a execu
|
|||
}
|
||||
bucketID = b
|
||||
} else {
|
||||
bucketID = id.ID(spec.Database)
|
||||
bucketID = platform.ID(spec.Database)
|
||||
}
|
||||
|
||||
return storage.NewSource(
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/semantic"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -19,7 +18,7 @@ type HostLookup interface {
|
|||
}
|
||||
|
||||
type BucketLookup interface {
|
||||
Lookup(orgID id.ID, name string) (id.ID, bool)
|
||||
Lookup(orgID platform.ID, name string) (platform.ID, bool)
|
||||
}
|
||||
|
||||
type OrganizationLookup interface {
|
||||
|
|
|
@ -1,51 +1,8 @@
|
|||
// Package id exports one type, ID, which is aliased to github.com/influxdata/platform.ID.
|
||||
// This package was introduced when the query code was in the separate ifql repository,
|
||||
// and this type alias is provided only temporarily until other repositories have migrated to platform.ID.
|
||||
package id
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
)
|
||||
import "github.com/influxdata/platform"
|
||||
|
||||
// TODO(nathanielc): This code is copied, once we have the monorepos sorted, we need to import this code.
|
||||
|
||||
// ID is a unique identifier.
|
||||
type ID []byte
|
||||
|
||||
// Decode parses b as a hex-encoded byte-slice-string.
|
||||
func (i *ID) Decode(b []byte) error {
|
||||
dst := make([]byte, hex.DecodedLen(len(b)))
|
||||
_, err := hex.Decode(dst, b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = dst
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeFromString parses s as a hex-encoded string.
|
||||
func (i *ID) DecodeFromString(s string) error {
|
||||
return i.Decode([]byte(s))
|
||||
}
|
||||
|
||||
// Encode converts ID to a hex-encoded byte-slice-string.
|
||||
func (i ID) Encode() []byte {
|
||||
dst := make([]byte, hex.EncodedLen(len(i)))
|
||||
hex.Encode(dst, i)
|
||||
return dst
|
||||
}
|
||||
|
||||
// String returns the ID as a hex encoded string
|
||||
func (i *ID) String() string {
|
||||
return string(i.Encode())
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements JSON unmarshaller for IDs.
|
||||
func (i *ID) UnmarshalJSON(b []byte) error {
|
||||
b = b[1 : len(b)-1]
|
||||
return i.Decode(b)
|
||||
}
|
||||
|
||||
// MarshalJSON implements JSON marshaller for IDs.
|
||||
func (i ID) MarshalJSON() ([]byte, error) {
|
||||
id := i.Encode()
|
||||
return json.Marshal(string(id[:]))
|
||||
}
|
||||
type ID = platform.ID
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/control"
|
||||
"github.com/influxdata/platform/query/functions"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -30,12 +29,12 @@ type wrapController struct {
|
|||
}
|
||||
|
||||
func (c wrapController) Query(ctx context.Context, orgID platform.ID, query *query.Spec) (query.Query, error) {
|
||||
q, err := c.Controller.Query(ctx, id.ID(orgID), query)
|
||||
q, err := c.Controller.Query(ctx, orgID, query)
|
||||
return q, err
|
||||
}
|
||||
|
||||
func (c wrapController) QueryWithCompile(ctx context.Context, orgID platform.ID, query string) (query.Query, error) {
|
||||
q, err := c.Controller.QueryWithCompile(ctx, id.ID(orgID), query)
|
||||
q, err := c.Controller.QueryWithCompile(ctx, orgID, query)
|
||||
return q, err
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
prompt "github.com/c-bata/go-prompt"
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/query"
|
||||
"github.com/influxdata/platform/query/control"
|
||||
"github.com/influxdata/platform/query/execute"
|
||||
"github.com/influxdata/platform/query/functions"
|
||||
"github.com/influxdata/platform/query/id"
|
||||
"github.com/influxdata/platform/query/interpreter"
|
||||
"github.com/influxdata/platform/query/parser"
|
||||
"github.com/influxdata/platform/query/semantic"
|
||||
|
@ -28,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
type REPL struct {
|
||||
orgID id.ID
|
||||
orgID platform.ID
|
||||
|
||||
scope *interpreter.Scope
|
||||
declarations semantic.DeclarationScope
|
||||
|
@ -54,7 +54,7 @@ func addBuiltIn(script string, scope *interpreter.Scope, declarations semantic.D
|
|||
return nil
|
||||
}
|
||||
|
||||
func New(c *control.Controller, orgID id.ID) *REPL {
|
||||
func New(c *control.Controller, orgID platform.ID) *REPL {
|
||||
scope, declarations := query.BuiltIns()
|
||||
interpScope := interpreter.NewScopeWithValues(scope)
|
||||
addBuiltIn("run = () => yield(table:_)", interpScope, declarations)
|
||||
|
|
Loading…
Reference in New Issue