mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-15 07:18:04 +00:00
i used this script, a little clunky but it got the job done
```bash
for file in `find . -type f -print | grep '\.go'`; do
sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
result=`cat $file.tmp`
if [[ result != "" ]]; then
gofmt $file.tmp &> /dev/null;
if [[ $? == 0 ]]; then
mv $file.tmp $file && gofmt -w $file;
else
rm $file.tmp;
fi
else
rm $file.tmp;
fi
done
```
127 lines
2.1 KiB
Go
127 lines
2.1 KiB
Go
package sql
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/molecula/featurebase/v2"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
var (
|
|
ErrUnsupportedQuery = errors.New("unsupported query")
|
|
)
|
|
|
|
// TODO: what the difference between this and IDIndexColumn?
|
|
type KeyIndexColumn struct {
|
|
Index *pilosa.Index
|
|
text string
|
|
alias string
|
|
}
|
|
|
|
func NewKeyIndexColumn(index *pilosa.Index, alias string) *KeyIndexColumn {
|
|
return &KeyIndexColumn{
|
|
Index: index,
|
|
text: ColID,
|
|
alias: alias,
|
|
}
|
|
}
|
|
|
|
func (i *KeyIndexColumn) Source() string {
|
|
return "" // TODO
|
|
}
|
|
func (i *KeyIndexColumn) Name() string {
|
|
return i.text
|
|
}
|
|
func (i *KeyIndexColumn) Alias() string {
|
|
if i.alias != "" {
|
|
return i.alias
|
|
}
|
|
return i.Name()
|
|
}
|
|
|
|
type IDIndexColumn struct {
|
|
Index *pilosa.Index
|
|
text string
|
|
alias string
|
|
}
|
|
|
|
func NewIDIndexColumn(index *pilosa.Index, alias string) *IDIndexColumn {
|
|
return &IDIndexColumn{
|
|
Index: index,
|
|
text: ColID,
|
|
alias: alias,
|
|
}
|
|
}
|
|
|
|
func (i *IDIndexColumn) Source() string {
|
|
return "" // TODO
|
|
}
|
|
func (i *IDIndexColumn) Name() string {
|
|
return i.text
|
|
}
|
|
func (i *IDIndexColumn) Alias() string {
|
|
if i.alias != "" {
|
|
return i.alias
|
|
}
|
|
return i.Name()
|
|
}
|
|
|
|
type FieldColumn struct {
|
|
Field *pilosa.Field
|
|
text string
|
|
alias string
|
|
}
|
|
|
|
func NewFieldColumn(field *pilosa.Field, alias string) *FieldColumn {
|
|
return &FieldColumn{
|
|
Field: field,
|
|
text: field.Name(),
|
|
alias: alias,
|
|
}
|
|
}
|
|
|
|
func (f *FieldColumn) Source() string {
|
|
return ""
|
|
}
|
|
func (f *FieldColumn) Name() string {
|
|
return f.text
|
|
}
|
|
func (f *FieldColumn) Alias() string {
|
|
if f.alias != "" {
|
|
return f.alias
|
|
}
|
|
return f.Name()
|
|
}
|
|
|
|
type FuncColumn struct {
|
|
Field *pilosa.Field
|
|
FuncName FuncName
|
|
alias string
|
|
}
|
|
|
|
func NewFuncColumn(funcName FuncName, field *pilosa.Field, alias string) *FuncColumn {
|
|
return &FuncColumn{
|
|
Field: field,
|
|
FuncName: funcName,
|
|
alias: alias,
|
|
}
|
|
}
|
|
|
|
func (f *FuncColumn) Source() string {
|
|
return string(f.FuncName)
|
|
}
|
|
|
|
func (f *FuncColumn) Name() string {
|
|
fieldName := "*"
|
|
if f.Field != nil {
|
|
fieldName = f.Field.Name()
|
|
}
|
|
return fmt.Sprintf("%s(%s)", f.FuncName, fieldName)
|
|
}
|
|
|
|
func (f *FuncColumn) Alias() string {
|
|
if f.alias != "" {
|
|
return f.alias
|
|
}
|
|
return f.Name()
|
|
}
|