Skip to content

Commit

Permalink
fix: Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Aug 9, 2024
1 parent e3ddab5 commit a2bab83
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
15 changes: 14 additions & 1 deletion parquet/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
var allowedVersions = []string{"v1.0", "v2.4", "v2.6", "v2Latest"}
var allowedRootRepetitions = []string{"undefined", "required", "optional", "repeated"}

// nolint:revive
type ParquetSpec struct {
Version string `json:"version,omitempty"`
RootRepetition string `json:"root_repetition,omitempty"`
Expand Down Expand Up @@ -47,7 +48,7 @@ func (s *ParquetSpec) GetRootRepetition() parquet.Repetition {

func (ParquetSpec) JSONSchema() *jsonschema.Schema {
properties := jsonschema.NewProperties()
allowedVersionsAsAny := make([]interface{}, len(allowedVersions))
allowedVersionsAsAny := make([]any, len(allowedVersions))
for i, v := range allowedVersions {
allowedVersionsAsAny[i] = v
}
Expand All @@ -57,6 +58,18 @@ func (ParquetSpec) JSONSchema() *jsonschema.Schema {
Enum: allowedVersionsAsAny,
Default: "v2Latest",
})

allowedRootRepetitionsAsAny := make([]any, len(allowedRootRepetitions))
for i, v := range allowedRootRepetitions {
allowedRootRepetitionsAsAny[i] = v
}
properties.Set("root_repetition", &jsonschema.Schema{
Type: "string",
Description: "Root repetition",
Enum: allowedRootRepetitionsAsAny,
Default: "repeated",
})

return &jsonschema.Schema{
Description: "CloudQuery Parquet file output spec.",
Properties: properties,
Expand Down
9 changes: 9 additions & 0 deletions parquet/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,14 @@ func TestSpec_JSONSchema(t *testing.T) {
Name: "valid version",
Spec: `{"version":"v1.0"}`,
},
{
Name: "valid root_repetition",
Spec: `{"root_repetition":"undefined"}`,
},
{
Name: "invalid root_repetition",
ErrorMessage: "at '/root_repetition': value must be one of 'undefined', 'required', 'optional', 'repeated'",
Spec: `{"root_repetition":"invalid"}`,
},
})
}
11 changes: 11 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@
],
"description": "Parquet format version",
"default": "v2Latest"
},
"root_repetition": {
"type": "string",
"enum": [
"undefined",
"required",
"optional",
"repeated"
],
"description": "Root repetition",
"default": "repeated"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit a2bab83

Please sign in to comment.