featurebase/sql3/planner/opdroptable.go
pokeeffe-molecula 74ee3ebf0e implemented DISTINCT (fb-1562) (#2388)
* implemented distinct

* implemented distinct
* uses first cut of a buffer pool, and extendible hashing with thresholded spill to disk
* tests
* cleaned up some stuff around query plan output to make developing tooling easier
* added optimization to call PQL Distinct()

* fixed test

* fix for passing wrong index name in orchestrator

* back out change to DistinctTimestamp

* fix other instance of wrong table name being passed

* use full index name instead of abbreviated one for translation. sigh.

* removed some unused code

Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
(cherry picked from commit f030d58d95)
2023-01-10 23:28:00 +00:00

85 lines
1.9 KiB
Go

// Copyright 2021 Molecula Corp. All rights reserved.
package planner
import (
"context"
"fmt"
pilosa "github.com/featurebasedb/featurebase/v3"
"github.com/featurebasedb/featurebase/v3/dax"
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
)
// PlanOpDropTable plan operator to drop a table.
type PlanOpDropTable struct {
planner *ExecutionPlanner
index *pilosa.IndexInfo
warnings []string
}
func NewPlanOpDropTable(p *ExecutionPlanner, index *pilosa.IndexInfo) *PlanOpDropTable {
return &PlanOpDropTable{
planner: p,
index: index,
warnings: make([]string, 0),
}
}
func (p *PlanOpDropTable) Plan() map[string]interface{} {
result := make(map[string]interface{})
result["_op"] = fmt.Sprintf("%T", p)
result["tableName"] = p.index.Name
return result
}
func (p *PlanOpDropTable) String() string {
return ""
}
func (p *PlanOpDropTable) AddWarning(warning string) {
p.warnings = append(p.warnings, warning)
}
func (p *PlanOpDropTable) Warnings() []string {
return p.warnings
}
func (p *PlanOpDropTable) Schema() types.Schema {
return types.Schema{}
}
func (p *PlanOpDropTable) Children() []types.PlanOperator {
return []types.PlanOperator{}
}
func (p *PlanOpDropTable) Iterator(ctx context.Context, row types.Row) (types.RowIterator, error) {
return &dropTableRowIter{
planner: p.planner,
index: p.index,
}, nil
}
func (p *PlanOpDropTable) WithChildren(children ...types.PlanOperator) (types.PlanOperator, error) {
return nil, nil
}
type dropTableRowIter struct {
planner *ExecutionPlanner
index *pilosa.IndexInfo
}
var _ types.RowIterator = (*dropTableRowIter)(nil)
func (i *dropTableRowIter) Next(ctx context.Context) (types.Row, error) {
err := i.planner.checkAccess(ctx, i.index.Name, accessTypeDropObject)
if err != nil {
return nil, err
}
err = i.planner.schemaAPI.DeleteTable(ctx, dax.TableName(i.index.Name))
if err != nil {
return nil, err
}
return nil, types.ErrNoMoreRows
}