Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Nov 6, 2023
1 parent 3199dbb commit 236bbce
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 23 deletions.
5 changes: 5 additions & 0 deletions pkg/sdk/poc/generator/query_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (v *QueryStruct) WithValidation(validationType ValidationType, fieldNames .
return v
}

func (v *QueryStruct) PredefinedQueryStructField(name string, kind string, transformer FieldTransformer) *QueryStruct {
v.fields = append(v.fields, NewField(name, kind, Tags(), transformer))
return v
}

func (v *QueryStruct) QueryStructField(name string, queryStruct *QueryStruct, transformer FieldTransformer) *QueryStruct {
return v.queryStructField(name, queryStruct, "", transformer)
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/sdk/stages_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ var (
StageCopyColumnMapCaseNone StageCopyColumnMapOption = "NONE"
)

// TODO PUT, GET, LS, etc. ???

func createStageOperation(structName string, apply func(qs *g.QueryStruct) *g.QueryStruct) *g.QueryStruct {
qs := g.NewQueryStruct(structName).
Create().
Expand Down Expand Up @@ -78,16 +76,17 @@ func alterStageOperation(structName string, apply func(qs *g.QueryStruct) *g.Que

var stageFileFormatDef = g.NewQueryStruct("StageFileFormat").
OptionalTextAssignment("FORMAT_NAME", g.ParameterOptions().SingleQuotes()).
OptionalAssignment("TYPE", g.KindOfTPointer[FileFormatType](), g.ParameterOptions())
OptionalAssignment("TYPE", g.KindOfTPointer[FileFormatType](), g.ParameterOptions()).
PredefinedQueryStructField("Options", g.KindOfTPointer[FileFormatTypeOptions](), g.ListOptions().NoComma())

var stageCopyOptionsDef = g.NewQueryStruct("StageCopyOptions").
OptionalQueryStructField(
"OnError",
g.NewQueryStruct("StageCopyOnErrorOptions").
OptionalSQL("CONTINUE").
OptionalSQL("SKIP_FILE").
//OptionalSQL("SKIP_FILE_n"). // TODO templated value - not even supported by structToSQL (I think)
//OptionalSQL("SKIP_FILE_n%"). // TODO templated value with % - not even supported by structToSQL (I think)
//OptionalSQL("SKIP_FILE_n"). // TODO templated value - not even supported by structToSQL

Check failure on line 88 in pkg/sdk/stages_def.go

View workflow job for this annotation

GitHub Actions / golang-ci

commentFormatting: put a space between `//` and comment text (gocritic)

Check failure on line 88 in pkg/sdk/stages_def.go

View workflow job for this annotation

GitHub Actions / golang-ci

[golangci] commentFormatting: put a space between `//` and comment text (gocritic)
//OptionalSQL("SKIP_FILE_n%"). // TODO templated value with % - not even supported by structToSQL
OptionalSQL("ABORT_STATEMENT"),
g.ParameterOptions().SQL("ON_ERROR"),
).
Expand Down
5 changes: 0 additions & 5 deletions pkg/sdk/stages_dto_builders_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pkg/sdk/stages_dto_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type InternalDirectoryTableOptionsRequest struct {
type StageFileFormatRequest struct {
FormatName *string
Type *FileFormatType
TYPE []FileFormatType
}

type StageCopyOptionsRequest struct {
Expand Down
5 changes: 2 additions & 3 deletions pkg/sdk/stages_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ type InternalDirectoryTableOptions struct {
}

type StageFileFormat struct {
FormatName *string `ddl:"parameter,single_quotes" sql:"FORMAT_NAME"`
Type *FileFormatType `ddl:"parameter" sql:"TYPE"`
TYPE []FileFormatType `ddl:"list"`
FormatName *string `ddl:"parameter,single_quotes" sql:"FORMAT_NAME"`
Type *FileFormatType `ddl:"parameter" sql:"TYPE"`
}

type StageCopyOptions struct {
Expand Down
9 changes: 0 additions & 9 deletions pkg/sdk/stages_impl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (r *CreateInternalStageRequest) toOpts() *CreateInternalStageOptions {
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -199,7 +198,6 @@ func (r *CreateOnS3StageRequest) toOpts() *CreateOnS3StageOptions {
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -258,7 +256,6 @@ func (r *CreateOnGCSStageRequest) toOpts() *CreateOnGCSStageOptions {
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -322,7 +319,6 @@ func (r *CreateOnAzureStageRequest) toOpts() *CreateOnAzureStageOptions {
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -376,7 +372,6 @@ func (r *CreateOnS3CompatibleStageRequest) toOpts() *CreateOnS3CompatibleStageOp
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -423,7 +418,6 @@ func (r *AlterInternalStageStageRequest) toOpts() *AlterInternalStageStageOption
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -480,7 +474,6 @@ func (r *AlterExternalS3StageStageRequest) toOpts() *AlterExternalS3StageStageOp
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -528,7 +521,6 @@ func (r *AlterExternalGCSStageStageRequest) toOpts() *AlterExternalGCSStageStage
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down Expand Up @@ -581,7 +573,6 @@ func (r *AlterExternalAzureStageStageRequest) toOpts() *AlterExternalAzureStageS
opts.FileFormat = &StageFileFormat{
FormatName: r.FileFormat.FormatName,
Type: r.FileFormat.Type,
TYPE: r.FileFormat.TYPE,
}
}
if r.CopyOptions != nil {
Expand Down

0 comments on commit 236bbce

Please sign in to comment.