Skip to content

Commit

Permalink
treat default of supported_as_column as true in dialect (#56)
Browse files Browse the repository at this point in the history
* treat default of supported_as_column as true in dialect
  • Loading branch information
scgkiran authored Sep 19, 2024
1 parent 18c1a41 commit db135fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 15 additions & 1 deletion functions/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"strings"

"github.com/creasty/defaults"
"github.com/goccy/go-yaml"
substraitgo "github.com/substrait-io/substrait-go"
"github.com/substrait-io/substrait-go/extensions"
Expand Down Expand Up @@ -187,7 +188,20 @@ type dialectFile struct {

type dialectTypeInfo struct {
SqlTypeName string `yaml:"sql_type_name"`
SupportedAsColumn bool `yaml:"supported_as_column"`
SupportedAsColumn bool `yaml:"supported_as_column" default:"true"`
}

func (ti *dialectTypeInfo) UnmarshalYAML(unmarshal func(interface{}) error) error {
type alias dialectTypeInfo
aux := &alias{}
if err := defaults.Set(aux); err != nil {
return err
}
if err := unmarshal(aux); err != nil {
return err
}
*ti = dialectTypeInfo(*aux)
return nil
}

func (d *dialectFile) getUriAndFunctionName(df *dialectFunction) (string, string) {
Expand Down
9 changes: 2 additions & 7 deletions functions/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ supported_types:
supported_as_column: true
i64:
sql_type_name: int64
supported_as_column: true
supported_as_column: true
date:
sql_type_name: DATE
supported_as_column: true
Expand All @@ -112,16 +110,12 @@ supported_types:
supported_as_column: true
dec:
sql_type_name: NUMERIC
supported_as_column: true
vchar:
sql_type_name: VARCHAR
supported_as_column: true
fchar:
sql_type_name: CHAR
supported_as_column: true
fbin:
sql_type_name: BINARY
supported_as_column: true
scalar_functions:
- name: arithmetic.add
local_name: +
Expand Down Expand Up @@ -182,7 +176,8 @@ scalar_functions:
assert.NoError(t, err)
assert.Equal(t, tt.localName, localType)

assert.Equal(t, tt.asColumn, localTypeRegistry.IsTypeSupportedInTables(tt.want))
assert.Equal(t, tt.asColumn, localTypeRegistry.IsTypeSupportedInTables(tt.want),
"IsTypeSupportedInTables(%s) failed", tt.name)
})
}

Expand Down

0 comments on commit db135fe

Please sign in to comment.