Skip to content

Commit

Permalink
treat default of supported_as_column as true in dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
scgkiran committed Sep 16, 2024
1 parent 1a800d9 commit 1769fc0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 14 additions & 2 deletions functions/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ func (d *dialectImpl) LocalizeTypeRegistry(registry TypeRegistry) (LocalTypeRegi
if err != nil {
return nil, fmt.Errorf("%w: unknown type %v", substraitgo.ErrInvalidDialect, name)
}
typeInfos = append(typeInfos, typeInfo{typ: typ, shortName: name, localName: info.SqlTypeName, supportedAsColumn: info.SupportedAsColumn})
typeInfos = append(typeInfos, typeInfo{
typ: typ,
shortName: name,
localName: info.SqlTypeName,
supportedAsColumn: info.isSupportedAsColumn(),
})
}
return NewLocalTypeRegistry(typeInfos), nil
}
Expand Down Expand Up @@ -187,7 +192,14 @@ type dialectFile struct {

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

func (ti *dialectTypeInfo) isSupportedAsColumn() bool {
if ti.SupportedAsColumn == nil {
return true
}
return *ti.SupportedAsColumn
}

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 1769fc0

Please sign in to comment.