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

Conversation

scgkiran
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 55.13%. Comparing base (1a800d9) to head (961db09).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
functions/dialect.go 55.55% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #56   +/-   ##
=======================================
  Coverage   55.13%   55.13%           
=======================================
  Files          35       35           
  Lines        6861     6870    +9     
=======================================
+ Hits         3783     3788    +5     
- Misses       2885     2887    +2     
- Partials      193      195    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

functions/dialect.go Outdated Show resolved Hide resolved
functions/dialect.go Outdated Show resolved Hide resolved
functions/dialect.go Outdated Show resolved Hide resolved
}

type dialectTypeInfo struct {
SqlTypeName string `yaml:"sql_type_name"`
SupportedAsColumn bool `yaml:"supported_as_column"`
SupportedAsColumn *bool `yaml:"supported_as_column" default:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

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

let's avoid change to pointer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed for SetDefaults to differentiate the zero value from the provided value.

Without this it is incorrectly setting the value to true even if the input is
supported_as_column: false

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you resolve this by overriding UnmarshalJSON and having it set the defaults before doing the other operations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried UnmarshalYAML, one hiccup with this is we cannot use defaults.Set on any struct using dialectTypeInfo. I had to remove defaults.Set on dialectFile.

Looks like whenever we have default:"true" the choice is between 1. using pointer vs 2. adding UnmarshalYAML in all the structs (that includes this bool indirectly) to set the defaults.

LMK 1 or 2?

SupportedAsColumn *bool `yaml:"supported_as_column" default:"true"`
}

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.

Copy link
Contributor

@jacques-n jacques-n left a comment

Choose a reason for hiding this comment

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

lgtm

@jacques-n jacques-n merged commit db135fe into substrait-io:main Sep 19, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants