Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treat default of supported_as_column as true in dialect #56

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
scgkiran marked this conversation as resolved.
Show resolved Hide resolved
}

func (ti *dialectTypeInfo) isSupportedAsColumn() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't need to introduce this if we stay away from pointer.

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
Loading