featurebase/sql3/planner/opnulltable.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

69 lines
1.5 KiB
Go

// Copyright 2022 Molecula Corp. All rights reserved.
package planner
import (
"context"
"fmt"
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
)
// PlanOpNullTable is an operator for a null table
// basically when you do select 1, you're using the null table
type PlanOpNullTable struct {
warnings []string
}
func NewPlanOpNullTable() *PlanOpNullTable {
return &PlanOpNullTable{
warnings: make([]string, 0),
}
}
func (p *PlanOpNullTable) Schema() types.Schema {
return types.Schema{}
}
func (p *PlanOpNullTable) Iterator(ctx context.Context, row types.Row) (types.RowIterator, error) {
return &nullTableIterator{}, nil
}
func (p *PlanOpNullTable) WithChildren(children ...types.PlanOperator) (types.PlanOperator, error) {
return NewPlanOpNullTable(), nil
}
func (p *PlanOpNullTable) Children() []types.PlanOperator {
return []types.PlanOperator{}
}
func (p *PlanOpNullTable) Plan() map[string]interface{} {
result := make(map[string]interface{})
result["_op"] = fmt.Sprintf("%T", p)
result["_schema"] = p.Schema().Plan()
return result
}
func (p *PlanOpNullTable) String() string {
return ""
}
func (p *PlanOpNullTable) AddWarning(warning string) {
p.warnings = append(p.warnings, warning)
}
func (p *PlanOpNullTable) Warnings() []string {
return p.warnings
}
type nullTableIterator struct {
rowConsumed bool
}
func (i *nullTableIterator) Next(ctx context.Context) (types.Row, error) {
if !i.rowConsumed {
i.rowConsumed = true
return make([]interface{}, 0), nil
}
return nil, types.ErrNoMoreRows
}