diff --git a/pkg/datasources/external_tables.go b/pkg/datasources/external_tables.go index 1d48729804..429fac4a3c 100644 --- a/pkg/datasources/external_tables.go +++ b/pkg/datasources/external_tables.go @@ -67,7 +67,7 @@ func ReadExternalTables(d *schema.ResourceData, meta interface{}) error { schemaId := sdk.NewDatabaseObjectIdentifier(databaseName, schemaName) showIn := sdk.NewShowExternalTableInRequest().WithSchema(schemaId) - externalTables, err := client.ExternalTables.Show(ctx, sdk.NewShowExternalTableRequest().WithIn(showIn)) + externalTables, err := client.ExternalTables.Show(ctx, sdk.NewShowExternalTableRequest().WithIn(*showIn)) if err != nil { log.Printf("[DEBUG] failed when searching external tables in schema (%s), err = %s", schemaId.FullyQualifiedName(), err.Error()) d.SetId("") diff --git a/pkg/resources/external_table.go b/pkg/resources/external_table.go index 2732ea713c..bec15f6938 100644 --- a/pkg/resources/external_table.go +++ b/pkg/resources/external_table.go @@ -175,29 +175,18 @@ func CreateExternalTable(d *schema.ResourceData, meta any) error { columnDef["as"], ) } - autoRefresh := sdk.Bool(d.Get("auto_refresh").(bool)) - refreshOnCreate := sdk.Bool(d.Get("refresh_on_create").(bool)) - copyGrants := sdk.Bool(d.Get("copy_grants").(bool)) + autoRefresh := d.Get("auto_refresh").(bool) + refreshOnCreate := d.Get("refresh_on_create").(bool) + copyGrants := d.Get("copy_grants").(bool) var partitionBy []string if v, ok := d.GetOk("partition_by"); ok { partitionBy = expandStringList(v.([]any)) } - var pattern *string - if v, ok := d.GetOk("pattern"); ok { - pattern = sdk.String(v.(string)) - } - - var awsSnsTopic *string - if v, ok := d.GetOk("aws_sns_topic"); ok { - awsSnsTopic = sdk.String(v.(string)) - } - - var comment *string - if v, ok := d.GetOk("comment"); ok { - comment = sdk.String(v.(string)) - } + pattern, hasPattern := d.GetOk("pattern") + awsSnsTopic, hasAwsSnsTopic := d.GetOk("aws_sns_topic") + comment, hasComment := d.GetOk("comment") var tagAssociationRequests []*sdk.TagAssociationRequest if _, ok := d.GetOk("tag"); ok { @@ -210,36 +199,40 @@ func CreateExternalTable(d *schema.ResourceData, meta any) error { switch { case d.Get("table_format").(string) == "delta": - err := client.ExternalTables.CreateDeltaLake( - ctx, - sdk.NewCreateDeltaLakeExternalTableRequest(id, location). - WithColumns(columnRequests). - WithPartitionBy(partitionBy). - WithRefreshOnCreate(refreshOnCreate). - WithAutoRefresh(autoRefresh). - WithRawFileFormat(&fileFormat). - WithCopyGrants(copyGrants). - WithComment(comment). - WithTag(tagAssociationRequests), - ) + req := sdk.NewCreateDeltaLakeExternalTableRequest(id, location). + WithColumns(columnRequests). + WithPartitionBy(partitionBy). + WithRefreshOnCreate(refreshOnCreate). + WithAutoRefresh(autoRefresh). + WithRawFileFormat(fileFormat). + WithCopyGrants(copyGrants). + WithTag(tagAssociationRequests) + if hasComment { + req = req.WithComment(comment.(string)) + } + err := client.ExternalTables.CreateDeltaLake(ctx, req) if err != nil { return err } default: - err := client.ExternalTables.Create( - ctx, - sdk.NewCreateExternalTableRequest(id, location). - WithColumns(columnRequests). - WithPartitionBy(partitionBy). - WithRefreshOnCreate(refreshOnCreate). - WithAutoRefresh(autoRefresh). - WithPattern(pattern). - WithRawFileFormat(&fileFormat). - WithAwsSnsTopic(awsSnsTopic). - WithCopyGrants(copyGrants). - WithComment(comment). - WithTag(tagAssociationRequests), - ) + req := sdk.NewCreateExternalTableRequest(id, location). + WithColumns(columnRequests). + WithPartitionBy(partitionBy). + WithRefreshOnCreate(refreshOnCreate). + WithAutoRefresh(autoRefresh). + WithRawFileFormat(fileFormat). + WithCopyGrants(copyGrants). + WithTag(tagAssociationRequests) + if hasPattern { + req = req.WithPattern(pattern.(string)) + } + if hasAwsSnsTopic { + req = req.WithAwsSnsTopic(awsSnsTopic.(string)) + } + if hasComment { + req = req.WithComment(comment.(string)) + } + err := client.ExternalTables.Create(ctx, req) if err != nil { return err } diff --git a/pkg/sdk/dto-builder-generator/main.go b/pkg/sdk/dto-builder-generator/main.go index e751bd88cb..f3ba0f04c2 100644 --- a/pkg/sdk/dto-builder-generator/main.go +++ b/pkg/sdk/dto-builder-generator/main.go @@ -204,8 +204,15 @@ func (gen *Generator) generateBuilderMethods(d *structDef) { } for _, field := range optionalFields { - gen.printf("func (s *%s) With%s(%s %s) *%s {\n", d.name, toTitle(field.name), field.name, field.typeString, d.name) - gen.printf("s.%s = %s\n", field.name, field.name) + gen.printf("func (s *%s) With%s(%s %s) *%s {\n", d.name, toTitle(field.name), field.name, strings.TrimLeft(field.typeString, "*"), d.name) + + switch { + case strings.HasPrefix(field.typeString, "*"): + // If the target field is a pointer, assign the address of input field because right now we always pass them by value + gen.printf("s.%s = &%s\n", field.name, field.name) + default: + gen.printf("s.%s = %s\n", field.name, field.name) + } gen.printf("return s\n") gen.printf("}\n\n") } diff --git a/pkg/sdk/external_tables_dto_builders_gen.go b/pkg/sdk/external_tables_dto_builders_gen.go index e43109efe3..30373743d2 100644 --- a/pkg/sdk/external_tables_dto_builders_gen.go +++ b/pkg/sdk/external_tables_dto_builders_gen.go @@ -14,13 +14,13 @@ func NewCreateExternalTableRequest( return &s } -func (s *CreateExternalTableRequest) WithOrReplace(orReplace *bool) *CreateExternalTableRequest { - s.orReplace = orReplace +func (s *CreateExternalTableRequest) WithOrReplace(orReplace bool) *CreateExternalTableRequest { + s.orReplace = &orReplace return s } -func (s *CreateExternalTableRequest) WithIfNotExists(ifNotExists *bool) *CreateExternalTableRequest { - s.ifNotExists = ifNotExists +func (s *CreateExternalTableRequest) WithIfNotExists(ifNotExists bool) *CreateExternalTableRequest { + s.ifNotExists = &ifNotExists return s } @@ -29,8 +29,8 @@ func (s *CreateExternalTableRequest) WithColumns(columns []*ExternalTableColumnR return s } -func (s *CreateExternalTableRequest) WithCloudProviderParams(cloudProviderParams *CloudProviderParamsRequest) *CreateExternalTableRequest { - s.cloudProviderParams = cloudProviderParams +func (s *CreateExternalTableRequest) WithCloudProviderParams(cloudProviderParams CloudProviderParamsRequest) *CreateExternalTableRequest { + s.cloudProviderParams = &cloudProviderParams return s } @@ -39,48 +39,48 @@ func (s *CreateExternalTableRequest) WithPartitionBy(partitionBy []string) *Crea return s } -func (s *CreateExternalTableRequest) WithRefreshOnCreate(refreshOnCreate *bool) *CreateExternalTableRequest { - s.refreshOnCreate = refreshOnCreate +func (s *CreateExternalTableRequest) WithRefreshOnCreate(refreshOnCreate bool) *CreateExternalTableRequest { + s.refreshOnCreate = &refreshOnCreate return s } -func (s *CreateExternalTableRequest) WithAutoRefresh(autoRefresh *bool) *CreateExternalTableRequest { - s.autoRefresh = autoRefresh +func (s *CreateExternalTableRequest) WithAutoRefresh(autoRefresh bool) *CreateExternalTableRequest { + s.autoRefresh = &autoRefresh return s } -func (s *CreateExternalTableRequest) WithPattern(pattern *string) *CreateExternalTableRequest { - s.pattern = pattern +func (s *CreateExternalTableRequest) WithPattern(pattern string) *CreateExternalTableRequest { + s.pattern = &pattern return s } -func (s *CreateExternalTableRequest) WithRawFileFormat(rawFileFormat *string) *CreateExternalTableRequest { - s.rawFileFormat = rawFileFormat +func (s *CreateExternalTableRequest) WithRawFileFormat(rawFileFormat string) *CreateExternalTableRequest { + s.rawFileFormat = &rawFileFormat return s } -func (s *CreateExternalTableRequest) WithFileFormat(fileFormat *ExternalTableFileFormatRequest) *CreateExternalTableRequest { - s.fileFormat = fileFormat +func (s *CreateExternalTableRequest) WithFileFormat(fileFormat ExternalTableFileFormatRequest) *CreateExternalTableRequest { + s.fileFormat = &fileFormat return s } -func (s *CreateExternalTableRequest) WithAwsSnsTopic(awsSnsTopic *string) *CreateExternalTableRequest { - s.awsSnsTopic = awsSnsTopic +func (s *CreateExternalTableRequest) WithAwsSnsTopic(awsSnsTopic string) *CreateExternalTableRequest { + s.awsSnsTopic = &awsSnsTopic return s } -func (s *CreateExternalTableRequest) WithCopyGrants(copyGrants *bool) *CreateExternalTableRequest { - s.copyGrants = copyGrants +func (s *CreateExternalTableRequest) WithCopyGrants(copyGrants bool) *CreateExternalTableRequest { + s.copyGrants = ©Grants return s } -func (s *CreateExternalTableRequest) WithComment(comment *string) *CreateExternalTableRequest { - s.comment = comment +func (s *CreateExternalTableRequest) WithComment(comment string) *CreateExternalTableRequest { + s.comment = &comment return s } -func (s *CreateExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy *RowAccessPolicyRequest) *CreateExternalTableRequest { - s.rowAccessPolicy = rowAccessPolicy +func (s *CreateExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy RowAccessPolicyRequest) *CreateExternalTableRequest { + s.rowAccessPolicy = &rowAccessPolicy return s } @@ -101,13 +101,13 @@ func NewExternalTableColumnRequest( return &s } -func (s *ExternalTableColumnRequest) WithNotNull(notNull *bool) *ExternalTableColumnRequest { - s.notNull = notNull +func (s *ExternalTableColumnRequest) WithNotNull(notNull bool) *ExternalTableColumnRequest { + s.notNull = ¬Null return s } -func (s *ExternalTableColumnRequest) WithInlineConstraint(inlineConstraint *ColumnInlineConstraintRequest) *ExternalTableColumnRequest { - s.inlineConstraint = inlineConstraint +func (s *ExternalTableColumnRequest) WithInlineConstraint(inlineConstraint ColumnInlineConstraintRequest) *ExternalTableColumnRequest { + s.inlineConstraint = &inlineConstraint return s } @@ -115,13 +115,13 @@ func NewCloudProviderParamsRequest() *CloudProviderParamsRequest { return &CloudProviderParamsRequest{} } -func (s *CloudProviderParamsRequest) WithGoogleCloudStorageIntegration(googleCloudStorageIntegration *string) *CloudProviderParamsRequest { - s.googleCloudStorageIntegration = googleCloudStorageIntegration +func (s *CloudProviderParamsRequest) WithGoogleCloudStorageIntegration(googleCloudStorageIntegration string) *CloudProviderParamsRequest { + s.googleCloudStorageIntegration = &googleCloudStorageIntegration return s } -func (s *CloudProviderParamsRequest) WithMicrosoftAzureIntegration(microsoftAzureIntegration *string) *CloudProviderParamsRequest { - s.microsoftAzureIntegration = microsoftAzureIntegration +func (s *CloudProviderParamsRequest) WithMicrosoftAzureIntegration(microsoftAzureIntegration string) *CloudProviderParamsRequest { + s.microsoftAzureIntegration = µsoftAzureIntegration return s } @@ -129,18 +129,18 @@ func NewExternalTableFileFormatRequest() *ExternalTableFileFormatRequest { return &ExternalTableFileFormatRequest{} } -func (s *ExternalTableFileFormatRequest) WithName(name *string) *ExternalTableFileFormatRequest { - s.name = name +func (s *ExternalTableFileFormatRequest) WithName(name string) *ExternalTableFileFormatRequest { + s.name = &name return s } -func (s *ExternalTableFileFormatRequest) WithFileFormatType(fileFormatType *ExternalTableFileFormatType) *ExternalTableFileFormatRequest { - s.fileFormatType = fileFormatType +func (s *ExternalTableFileFormatRequest) WithFileFormatType(fileFormatType ExternalTableFileFormatType) *ExternalTableFileFormatRequest { + s.fileFormatType = &fileFormatType return s } -func (s *ExternalTableFileFormatRequest) WithOptions(options *ExternalTableFileFormatTypeOptionsRequest) *ExternalTableFileFormatRequest { - s.options = options +func (s *ExternalTableFileFormatRequest) WithOptions(options ExternalTableFileFormatTypeOptionsRequest) *ExternalTableFileFormatRequest { + s.options = &options return s } @@ -148,123 +148,123 @@ func NewExternalTableFileFormatTypeOptionsRequest() *ExternalTableFileFormatType return &ExternalTableFileFormatTypeOptionsRequest{} } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvCompression(csvCompression *ExternalTableCsvCompression) *ExternalTableFileFormatTypeOptionsRequest { - s.csvCompression = csvCompression +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvCompression(csvCompression ExternalTableCsvCompression) *ExternalTableFileFormatTypeOptionsRequest { + s.csvCompression = &csvCompression return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvRecordDelimiter(csvRecordDelimiter *string) *ExternalTableFileFormatTypeOptionsRequest { - s.csvRecordDelimiter = csvRecordDelimiter +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvRecordDelimiter(csvRecordDelimiter string) *ExternalTableFileFormatTypeOptionsRequest { + s.csvRecordDelimiter = &csvRecordDelimiter return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvFieldDelimiter(csvFieldDelimiter *string) *ExternalTableFileFormatTypeOptionsRequest { - s.csvFieldDelimiter = csvFieldDelimiter +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvFieldDelimiter(csvFieldDelimiter string) *ExternalTableFileFormatTypeOptionsRequest { + s.csvFieldDelimiter = &csvFieldDelimiter return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvSkipHeader(csvSkipHeader *int) *ExternalTableFileFormatTypeOptionsRequest { - s.csvSkipHeader = csvSkipHeader +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvSkipHeader(csvSkipHeader int) *ExternalTableFileFormatTypeOptionsRequest { + s.csvSkipHeader = &csvSkipHeader return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvSkipBlankLines(csvSkipBlankLines *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.csvSkipBlankLines = csvSkipBlankLines +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvSkipBlankLines(csvSkipBlankLines bool) *ExternalTableFileFormatTypeOptionsRequest { + s.csvSkipBlankLines = &csvSkipBlankLines return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEscapeUnenclosedField(csvEscapeUnenclosedField *string) *ExternalTableFileFormatTypeOptionsRequest { - s.csvEscapeUnenclosedField = csvEscapeUnenclosedField +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEscapeUnenclosedField(csvEscapeUnenclosedField string) *ExternalTableFileFormatTypeOptionsRequest { + s.csvEscapeUnenclosedField = &csvEscapeUnenclosedField return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvTrimSpace(csvTrimSpace *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.csvTrimSpace = csvTrimSpace +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvTrimSpace(csvTrimSpace bool) *ExternalTableFileFormatTypeOptionsRequest { + s.csvTrimSpace = &csvTrimSpace return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvFieldOptionallyEnclosedBy(csvFieldOptionallyEnclosedBy *string) *ExternalTableFileFormatTypeOptionsRequest { - s.csvFieldOptionallyEnclosedBy = csvFieldOptionallyEnclosedBy +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvFieldOptionallyEnclosedBy(csvFieldOptionallyEnclosedBy string) *ExternalTableFileFormatTypeOptionsRequest { + s.csvFieldOptionallyEnclosedBy = &csvFieldOptionallyEnclosedBy return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvNullIf(csvNullIf *[]NullStringRequest) *ExternalTableFileFormatTypeOptionsRequest { - s.csvNullIf = csvNullIf +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvNullIf(csvNullIf []NullStringRequest) *ExternalTableFileFormatTypeOptionsRequest { + s.csvNullIf = &csvNullIf return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEmptyFieldAsNull(csvEmptyFieldAsNull *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.csvEmptyFieldAsNull = csvEmptyFieldAsNull +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEmptyFieldAsNull(csvEmptyFieldAsNull bool) *ExternalTableFileFormatTypeOptionsRequest { + s.csvEmptyFieldAsNull = &csvEmptyFieldAsNull return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEncoding(csvEncoding *CSVEncoding) *ExternalTableFileFormatTypeOptionsRequest { - s.csvEncoding = csvEncoding +func (s *ExternalTableFileFormatTypeOptionsRequest) WithCsvEncoding(csvEncoding CSVEncoding) *ExternalTableFileFormatTypeOptionsRequest { + s.csvEncoding = &csvEncoding return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonCompression(jsonCompression *ExternalTableJsonCompression) *ExternalTableFileFormatTypeOptionsRequest { - s.jsonCompression = jsonCompression +func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonCompression(jsonCompression ExternalTableJsonCompression) *ExternalTableFileFormatTypeOptionsRequest { + s.jsonCompression = &jsonCompression return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonAllowDuplicate(jsonAllowDuplicate *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.jsonAllowDuplicate = jsonAllowDuplicate +func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonAllowDuplicate(jsonAllowDuplicate bool) *ExternalTableFileFormatTypeOptionsRequest { + s.jsonAllowDuplicate = &jsonAllowDuplicate return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonStripOuterArray(jsonStripOuterArray *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.jsonStripOuterArray = jsonStripOuterArray +func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonStripOuterArray(jsonStripOuterArray bool) *ExternalTableFileFormatTypeOptionsRequest { + s.jsonStripOuterArray = &jsonStripOuterArray return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonStripNullValues(jsonStripNullValues *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.jsonStripNullValues = jsonStripNullValues +func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonStripNullValues(jsonStripNullValues bool) *ExternalTableFileFormatTypeOptionsRequest { + s.jsonStripNullValues = &jsonStripNullValues return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonReplaceInvalidCharacters(jsonReplaceInvalidCharacters *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.jsonReplaceInvalidCharacters = jsonReplaceInvalidCharacters +func (s *ExternalTableFileFormatTypeOptionsRequest) WithJsonReplaceInvalidCharacters(jsonReplaceInvalidCharacters bool) *ExternalTableFileFormatTypeOptionsRequest { + s.jsonReplaceInvalidCharacters = &jsonReplaceInvalidCharacters return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithAvroCompression(avroCompression *ExternalTableAvroCompression) *ExternalTableFileFormatTypeOptionsRequest { - s.avroCompression = avroCompression +func (s *ExternalTableFileFormatTypeOptionsRequest) WithAvroCompression(avroCompression ExternalTableAvroCompression) *ExternalTableFileFormatTypeOptionsRequest { + s.avroCompression = &avroCompression return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithAvroReplaceInvalidCharacters(avroReplaceInvalidCharacters *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.avroReplaceInvalidCharacters = avroReplaceInvalidCharacters +func (s *ExternalTableFileFormatTypeOptionsRequest) WithAvroReplaceInvalidCharacters(avroReplaceInvalidCharacters bool) *ExternalTableFileFormatTypeOptionsRequest { + s.avroReplaceInvalidCharacters = &avroReplaceInvalidCharacters return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcTrimSpace(orcTrimSpace *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.orcTrimSpace = orcTrimSpace +func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcTrimSpace(orcTrimSpace bool) *ExternalTableFileFormatTypeOptionsRequest { + s.orcTrimSpace = &orcTrimSpace return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcReplaceInvalidCharacters(orcReplaceInvalidCharacters *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.orcReplaceInvalidCharacters = orcReplaceInvalidCharacters +func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcReplaceInvalidCharacters(orcReplaceInvalidCharacters bool) *ExternalTableFileFormatTypeOptionsRequest { + s.orcReplaceInvalidCharacters = &orcReplaceInvalidCharacters return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcNullIf(orcNullIf *[]NullStringRequest) *ExternalTableFileFormatTypeOptionsRequest { - s.orcNullIf = orcNullIf +func (s *ExternalTableFileFormatTypeOptionsRequest) WithOrcNullIf(orcNullIf []NullStringRequest) *ExternalTableFileFormatTypeOptionsRequest { + s.orcNullIf = &orcNullIf return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetCompression(parquetCompression *ExternalTableParquetCompression) *ExternalTableFileFormatTypeOptionsRequest { - s.parquetCompression = parquetCompression +func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetCompression(parquetCompression ExternalTableParquetCompression) *ExternalTableFileFormatTypeOptionsRequest { + s.parquetCompression = &parquetCompression return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetBinaryAsText(parquetBinaryAsText *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.parquetBinaryAsText = parquetBinaryAsText +func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetBinaryAsText(parquetBinaryAsText bool) *ExternalTableFileFormatTypeOptionsRequest { + s.parquetBinaryAsText = &parquetBinaryAsText return s } -func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetReplaceInvalidCharacters(parquetReplaceInvalidCharacters *bool) *ExternalTableFileFormatTypeOptionsRequest { - s.parquetReplaceInvalidCharacters = parquetReplaceInvalidCharacters +func (s *ExternalTableFileFormatTypeOptionsRequest) WithParquetReplaceInvalidCharacters(parquetReplaceInvalidCharacters bool) *ExternalTableFileFormatTypeOptionsRequest { + s.parquetReplaceInvalidCharacters = &parquetReplaceInvalidCharacters return s } @@ -287,13 +287,13 @@ func NewCreateWithManualPartitioningExternalTableRequest( return &s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithOrReplace(orReplace *bool) *CreateWithManualPartitioningExternalTableRequest { - s.orReplace = orReplace +func (s *CreateWithManualPartitioningExternalTableRequest) WithOrReplace(orReplace bool) *CreateWithManualPartitioningExternalTableRequest { + s.orReplace = &orReplace return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithIfNotExists(ifNotExists *bool) *CreateWithManualPartitioningExternalTableRequest { - s.ifNotExists = ifNotExists +func (s *CreateWithManualPartitioningExternalTableRequest) WithIfNotExists(ifNotExists bool) *CreateWithManualPartitioningExternalTableRequest { + s.ifNotExists = &ifNotExists return s } @@ -302,8 +302,8 @@ func (s *CreateWithManualPartitioningExternalTableRequest) WithColumns(columns [ return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithCloudProviderParams(cloudProviderParams *CloudProviderParamsRequest) *CreateWithManualPartitioningExternalTableRequest { - s.cloudProviderParams = cloudProviderParams +func (s *CreateWithManualPartitioningExternalTableRequest) WithCloudProviderParams(cloudProviderParams CloudProviderParamsRequest) *CreateWithManualPartitioningExternalTableRequest { + s.cloudProviderParams = &cloudProviderParams return s } @@ -312,28 +312,28 @@ func (s *CreateWithManualPartitioningExternalTableRequest) WithPartitionBy(parti return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithRawFileFormat(rawFileFormat *string) *CreateWithManualPartitioningExternalTableRequest { - s.rawFileFormat = rawFileFormat +func (s *CreateWithManualPartitioningExternalTableRequest) WithRawFileFormat(rawFileFormat string) *CreateWithManualPartitioningExternalTableRequest { + s.rawFileFormat = &rawFileFormat return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithFileFormat(fileFormat *ExternalTableFileFormatRequest) *CreateWithManualPartitioningExternalTableRequest { - s.fileFormat = fileFormat +func (s *CreateWithManualPartitioningExternalTableRequest) WithFileFormat(fileFormat ExternalTableFileFormatRequest) *CreateWithManualPartitioningExternalTableRequest { + s.fileFormat = &fileFormat return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithCopyGrants(copyGrants *bool) *CreateWithManualPartitioningExternalTableRequest { - s.copyGrants = copyGrants +func (s *CreateWithManualPartitioningExternalTableRequest) WithCopyGrants(copyGrants bool) *CreateWithManualPartitioningExternalTableRequest { + s.copyGrants = ©Grants return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithComment(comment *string) *CreateWithManualPartitioningExternalTableRequest { - s.comment = comment +func (s *CreateWithManualPartitioningExternalTableRequest) WithComment(comment string) *CreateWithManualPartitioningExternalTableRequest { + s.comment = &comment return s } -func (s *CreateWithManualPartitioningExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy *RowAccessPolicyRequest) *CreateWithManualPartitioningExternalTableRequest { - s.rowAccessPolicy = rowAccessPolicy +func (s *CreateWithManualPartitioningExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy RowAccessPolicyRequest) *CreateWithManualPartitioningExternalTableRequest { + s.rowAccessPolicy = &rowAccessPolicy return s } @@ -352,13 +352,13 @@ func NewCreateDeltaLakeExternalTableRequest( return &s } -func (s *CreateDeltaLakeExternalTableRequest) WithOrReplace(orReplace *bool) *CreateDeltaLakeExternalTableRequest { - s.orReplace = orReplace +func (s *CreateDeltaLakeExternalTableRequest) WithOrReplace(orReplace bool) *CreateDeltaLakeExternalTableRequest { + s.orReplace = &orReplace return s } -func (s *CreateDeltaLakeExternalTableRequest) WithIfNotExists(ifNotExists *bool) *CreateDeltaLakeExternalTableRequest { - s.ifNotExists = ifNotExists +func (s *CreateDeltaLakeExternalTableRequest) WithIfNotExists(ifNotExists bool) *CreateDeltaLakeExternalTableRequest { + s.ifNotExists = &ifNotExists return s } @@ -367,8 +367,8 @@ func (s *CreateDeltaLakeExternalTableRequest) WithColumns(columns []*ExternalTab return s } -func (s *CreateDeltaLakeExternalTableRequest) WithCloudProviderParams(cloudProviderParams *CloudProviderParamsRequest) *CreateDeltaLakeExternalTableRequest { - s.cloudProviderParams = cloudProviderParams +func (s *CreateDeltaLakeExternalTableRequest) WithCloudProviderParams(cloudProviderParams CloudProviderParamsRequest) *CreateDeltaLakeExternalTableRequest { + s.cloudProviderParams = &cloudProviderParams return s } @@ -377,38 +377,38 @@ func (s *CreateDeltaLakeExternalTableRequest) WithPartitionBy(partitionBy []stri return s } -func (s *CreateDeltaLakeExternalTableRequest) WithRefreshOnCreate(refreshOnCreate *bool) *CreateDeltaLakeExternalTableRequest { - s.refreshOnCreate = refreshOnCreate +func (s *CreateDeltaLakeExternalTableRequest) WithRefreshOnCreate(refreshOnCreate bool) *CreateDeltaLakeExternalTableRequest { + s.refreshOnCreate = &refreshOnCreate return s } -func (s *CreateDeltaLakeExternalTableRequest) WithAutoRefresh(autoRefresh *bool) *CreateDeltaLakeExternalTableRequest { - s.autoRefresh = autoRefresh +func (s *CreateDeltaLakeExternalTableRequest) WithAutoRefresh(autoRefresh bool) *CreateDeltaLakeExternalTableRequest { + s.autoRefresh = &autoRefresh return s } -func (s *CreateDeltaLakeExternalTableRequest) WithRawFileFormat(rawFileFormat *string) *CreateDeltaLakeExternalTableRequest { - s.rawFileFormat = rawFileFormat +func (s *CreateDeltaLakeExternalTableRequest) WithRawFileFormat(rawFileFormat string) *CreateDeltaLakeExternalTableRequest { + s.rawFileFormat = &rawFileFormat return s } -func (s *CreateDeltaLakeExternalTableRequest) WithFileFormat(fileFormat *ExternalTableFileFormatRequest) *CreateDeltaLakeExternalTableRequest { - s.fileFormat = fileFormat +func (s *CreateDeltaLakeExternalTableRequest) WithFileFormat(fileFormat ExternalTableFileFormatRequest) *CreateDeltaLakeExternalTableRequest { + s.fileFormat = &fileFormat return s } -func (s *CreateDeltaLakeExternalTableRequest) WithCopyGrants(copyGrants *bool) *CreateDeltaLakeExternalTableRequest { - s.copyGrants = copyGrants +func (s *CreateDeltaLakeExternalTableRequest) WithCopyGrants(copyGrants bool) *CreateDeltaLakeExternalTableRequest { + s.copyGrants = ©Grants return s } -func (s *CreateDeltaLakeExternalTableRequest) WithComment(comment *string) *CreateDeltaLakeExternalTableRequest { - s.comment = comment +func (s *CreateDeltaLakeExternalTableRequest) WithComment(comment string) *CreateDeltaLakeExternalTableRequest { + s.comment = &comment return s } -func (s *CreateDeltaLakeExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy *RowAccessPolicyRequest) *CreateDeltaLakeExternalTableRequest { - s.rowAccessPolicy = rowAccessPolicy +func (s *CreateDeltaLakeExternalTableRequest) WithRowAccessPolicy(rowAccessPolicy RowAccessPolicyRequest) *CreateDeltaLakeExternalTableRequest { + s.rowAccessPolicy = &rowAccessPolicy return s } @@ -427,13 +427,13 @@ func NewCreateExternalTableUsingTemplateRequest( return &s } -func (s *CreateExternalTableUsingTemplateRequest) WithOrReplace(orReplace *bool) *CreateExternalTableUsingTemplateRequest { - s.orReplace = orReplace +func (s *CreateExternalTableUsingTemplateRequest) WithOrReplace(orReplace bool) *CreateExternalTableUsingTemplateRequest { + s.orReplace = &orReplace return s } -func (s *CreateExternalTableUsingTemplateRequest) WithCopyGrants(copyGrants *bool) *CreateExternalTableUsingTemplateRequest { - s.copyGrants = copyGrants +func (s *CreateExternalTableUsingTemplateRequest) WithCopyGrants(copyGrants bool) *CreateExternalTableUsingTemplateRequest { + s.copyGrants = ©Grants return s } @@ -442,8 +442,8 @@ func (s *CreateExternalTableUsingTemplateRequest) WithQuery(query string) *Creat return s } -func (s *CreateExternalTableUsingTemplateRequest) WithCloudProviderParams(cloudProviderParams *CloudProviderParamsRequest) *CreateExternalTableUsingTemplateRequest { - s.cloudProviderParams = cloudProviderParams +func (s *CreateExternalTableUsingTemplateRequest) WithCloudProviderParams(cloudProviderParams CloudProviderParamsRequest) *CreateExternalTableUsingTemplateRequest { + s.cloudProviderParams = &cloudProviderParams return s } @@ -452,43 +452,43 @@ func (s *CreateExternalTableUsingTemplateRequest) WithPartitionBy(partitionBy [] return s } -func (s *CreateExternalTableUsingTemplateRequest) WithRefreshOnCreate(refreshOnCreate *bool) *CreateExternalTableUsingTemplateRequest { - s.refreshOnCreate = refreshOnCreate +func (s *CreateExternalTableUsingTemplateRequest) WithRefreshOnCreate(refreshOnCreate bool) *CreateExternalTableUsingTemplateRequest { + s.refreshOnCreate = &refreshOnCreate return s } -func (s *CreateExternalTableUsingTemplateRequest) WithAutoRefresh(autoRefresh *bool) *CreateExternalTableUsingTemplateRequest { - s.autoRefresh = autoRefresh +func (s *CreateExternalTableUsingTemplateRequest) WithAutoRefresh(autoRefresh bool) *CreateExternalTableUsingTemplateRequest { + s.autoRefresh = &autoRefresh return s } -func (s *CreateExternalTableUsingTemplateRequest) WithPattern(pattern *string) *CreateExternalTableUsingTemplateRequest { - s.pattern = pattern +func (s *CreateExternalTableUsingTemplateRequest) WithPattern(pattern string) *CreateExternalTableUsingTemplateRequest { + s.pattern = &pattern return s } -func (s *CreateExternalTableUsingTemplateRequest) WithRawFileFormat(rawFileFormat *string) *CreateExternalTableUsingTemplateRequest { - s.rawFileFormat = rawFileFormat +func (s *CreateExternalTableUsingTemplateRequest) WithRawFileFormat(rawFileFormat string) *CreateExternalTableUsingTemplateRequest { + s.rawFileFormat = &rawFileFormat return s } -func (s *CreateExternalTableUsingTemplateRequest) WithFileFormat(fileFormat *ExternalTableFileFormatRequest) *CreateExternalTableUsingTemplateRequest { - s.fileFormat = fileFormat +func (s *CreateExternalTableUsingTemplateRequest) WithFileFormat(fileFormat ExternalTableFileFormatRequest) *CreateExternalTableUsingTemplateRequest { + s.fileFormat = &fileFormat return s } -func (s *CreateExternalTableUsingTemplateRequest) WithAwsSnsTopic(awsSnsTopic *string) *CreateExternalTableUsingTemplateRequest { - s.awsSnsTopic = awsSnsTopic +func (s *CreateExternalTableUsingTemplateRequest) WithAwsSnsTopic(awsSnsTopic string) *CreateExternalTableUsingTemplateRequest { + s.awsSnsTopic = &awsSnsTopic return s } -func (s *CreateExternalTableUsingTemplateRequest) WithComment(comment *string) *CreateExternalTableUsingTemplateRequest { - s.comment = comment +func (s *CreateExternalTableUsingTemplateRequest) WithComment(comment string) *CreateExternalTableUsingTemplateRequest { + s.comment = &comment return s } -func (s *CreateExternalTableUsingTemplateRequest) WithRowAccessPolicy(rowAccessPolicy *RowAccessPolicyRequest) *CreateExternalTableUsingTemplateRequest { - s.rowAccessPolicy = rowAccessPolicy +func (s *CreateExternalTableUsingTemplateRequest) WithRowAccessPolicy(rowAccessPolicy RowAccessPolicyRequest) *CreateExternalTableUsingTemplateRequest { + s.rowAccessPolicy = &rowAccessPolicy return s } @@ -505,13 +505,13 @@ func NewAlterExternalTableRequest( return &s } -func (s *AlterExternalTableRequest) WithIfExists(ifExists *bool) *AlterExternalTableRequest { - s.ifExists = ifExists +func (s *AlterExternalTableRequest) WithIfExists(ifExists bool) *AlterExternalTableRequest { + s.ifExists = &ifExists return s } -func (s *AlterExternalTableRequest) WithRefresh(refresh *RefreshExternalTableRequest) *AlterExternalTableRequest { - s.refresh = refresh +func (s *AlterExternalTableRequest) WithRefresh(refresh RefreshExternalTableRequest) *AlterExternalTableRequest { + s.refresh = &refresh return s } @@ -525,8 +525,8 @@ func (s *AlterExternalTableRequest) WithRemoveFiles(removeFiles []*ExternalTable return s } -func (s *AlterExternalTableRequest) WithAutoRefresh(autoRefresh *bool) *AlterExternalTableRequest { - s.autoRefresh = autoRefresh +func (s *AlterExternalTableRequest) WithAutoRefresh(autoRefresh bool) *AlterExternalTableRequest { + s.autoRefresh = &autoRefresh return s } @@ -564,8 +564,8 @@ func NewAlterExternalTablePartitionRequest( return &s } -func (s *AlterExternalTablePartitionRequest) WithIfExists(ifExists *bool) *AlterExternalTablePartitionRequest { - s.ifExists = ifExists +func (s *AlterExternalTablePartitionRequest) WithIfExists(ifExists bool) *AlterExternalTablePartitionRequest { + s.ifExists = &ifExists return s } @@ -574,8 +574,8 @@ func (s *AlterExternalTablePartitionRequest) WithAddPartitions(addPartitions []* return s } -func (s *AlterExternalTablePartitionRequest) WithDropPartition(dropPartition *bool) *AlterExternalTablePartitionRequest { - s.dropPartition = dropPartition +func (s *AlterExternalTablePartitionRequest) WithDropPartition(dropPartition bool) *AlterExternalTablePartitionRequest { + s.dropPartition = &dropPartition return s } @@ -602,13 +602,13 @@ func NewDropExternalTableRequest( return &s } -func (s *DropExternalTableRequest) WithIfExists(ifExists *bool) *DropExternalTableRequest { - s.ifExists = ifExists +func (s *DropExternalTableRequest) WithIfExists(ifExists bool) *DropExternalTableRequest { + s.ifExists = &ifExists return s } -func (s *DropExternalTableRequest) WithDropOption(dropOption *ExternalTableDropOptionRequest) *DropExternalTableRequest { - s.dropOption = dropOption +func (s *DropExternalTableRequest) WithDropOption(dropOption ExternalTableDropOptionRequest) *DropExternalTableRequest { + s.dropOption = &dropOption return s } @@ -616,13 +616,13 @@ func NewExternalTableDropOptionRequest() *ExternalTableDropOptionRequest { return &ExternalTableDropOptionRequest{} } -func (s *ExternalTableDropOptionRequest) WithRestrict(restrict *bool) *ExternalTableDropOptionRequest { - s.restrict = restrict +func (s *ExternalTableDropOptionRequest) WithRestrict(restrict bool) *ExternalTableDropOptionRequest { + s.restrict = &restrict return s } -func (s *ExternalTableDropOptionRequest) WithCascade(cascade *bool) *ExternalTableDropOptionRequest { - s.cascade = cascade +func (s *ExternalTableDropOptionRequest) WithCascade(cascade bool) *ExternalTableDropOptionRequest { + s.cascade = &cascade return s } @@ -630,28 +630,28 @@ func NewShowExternalTableRequest() *ShowExternalTableRequest { return &ShowExternalTableRequest{} } -func (s *ShowExternalTableRequest) WithTerse(terse *bool) *ShowExternalTableRequest { - s.terse = terse +func (s *ShowExternalTableRequest) WithTerse(terse bool) *ShowExternalTableRequest { + s.terse = &terse return s } -func (s *ShowExternalTableRequest) WithLike(like *string) *ShowExternalTableRequest { - s.like = like +func (s *ShowExternalTableRequest) WithLike(like string) *ShowExternalTableRequest { + s.like = &like return s } -func (s *ShowExternalTableRequest) WithIn(in *ShowExternalTableInRequest) *ShowExternalTableRequest { - s.in = in +func (s *ShowExternalTableRequest) WithIn(in ShowExternalTableInRequest) *ShowExternalTableRequest { + s.in = &in return s } -func (s *ShowExternalTableRequest) WithStartsWith(startsWith *string) *ShowExternalTableRequest { - s.startsWith = startsWith +func (s *ShowExternalTableRequest) WithStartsWith(startsWith string) *ShowExternalTableRequest { + s.startsWith = &startsWith return s } -func (s *ShowExternalTableRequest) WithLimitFrom(limitFrom *LimitFromRequest) *ShowExternalTableRequest { - s.limitFrom = limitFrom +func (s *ShowExternalTableRequest) WithLimitFrom(limitFrom LimitFromRequest) *ShowExternalTableRequest { + s.limitFrom = &limitFrom return s } @@ -659,8 +659,8 @@ func NewShowExternalTableInRequest() *ShowExternalTableInRequest { return &ShowExternalTableInRequest{} } -func (s *ShowExternalTableInRequest) WithAccount(account *bool) *ShowExternalTableInRequest { - s.account = account +func (s *ShowExternalTableInRequest) WithAccount(account bool) *ShowExternalTableInRequest { + s.account = &account return s } diff --git a/pkg/sdk/external_tables_impl.go b/pkg/sdk/external_tables_impl.go index 039d1f4aec..6e0a257d3f 100644 --- a/pkg/sdk/external_tables_impl.go +++ b/pkg/sdk/external_tables_impl.go @@ -55,8 +55,8 @@ func (v *externalTables) ShowByID(ctx context.Context, id SchemaObjectIdentifier } externalTables, err := v.client.ExternalTables.Show(ctx, NewShowExternalTableRequest(). - WithIn(NewShowExternalTableInRequest().WithSchema(NewDatabaseObjectIdentifier(id.DatabaseName(), id.SchemaName()))). - WithLike(String(id.Name()))) + WithIn(*NewShowExternalTableInRequest().WithSchema(NewDatabaseObjectIdentifier(id.DatabaseName(), id.SchemaName()))). + WithLike(id.Name())) if err != nil { return nil, err } diff --git a/pkg/sdk/poc/README.md b/pkg/sdk/poc/README.md index 9edf06d94c..69be9bcbdd 100644 --- a/pkg/sdk/poc/README.md +++ b/pkg/sdk/poc/README.md @@ -40,7 +40,6 @@ make clean-generator-session_policies run-generator-session_policies ### Next steps ##### Essentials -- fix builder generation (`With`s for optional fields should have required param, optional fields should not be exported in `Request` structs) - generate each branch of alter in tests (instead of basic and all options) - clean up predefined operations in generator (now casting to string) - (?) add mapping from db to plain struct (for now only "// TODO: Mapping" comment is generated) diff --git a/pkg/sdk/testint/external_tables_integration_test.go b/pkg/sdk/testint/external_tables_integration_test.go index a137368c35..50bff014ea 100644 --- a/pkg/sdk/testint/external_tables_integration_test.go +++ b/pkg/sdk/testint/external_tables_integration_test.go @@ -43,7 +43,7 @@ func TestInt_ExternalTables(t *testing.T) { return sdk.NewCreateExternalTableRequest( sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name), stageLocation, - ).WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeJSON)) + ).WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeJSON)) } createExternalTableWithManualPartitioningReq := func(name string) *sdk.CreateWithManualPartitioningExternalTableRequest { @@ -51,12 +51,12 @@ func TestInt_ExternalTables(t *testing.T) { sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name), stageLocation, ). - WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeJSON)). - WithOrReplace(sdk.Bool(true)). + WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeJSON)). + WithOrReplace(true). WithColumns(columnsWithPartition). WithPartitionBy([]string{"part_date"}). - WithCopyGrants(sdk.Bool(true)). - WithComment(sdk.String("some_comment")). + WithCopyGrants(true). + WithComment("some_comment"). WithTag([]*sdk.TagAssociationRequest{sdk.NewTagAssociationRequest(tag.ID(), "tag-value")}) } @@ -74,10 +74,7 @@ func TestInt_ExternalTables(t *testing.T) { t.Run("Create: with raw file format", func(t *testing.T) { name := random.AlphanumericN(32) externalTableID := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name) - err := client.ExternalTables.Create(ctx, minimalCreateExternalTableReq(name). - WithFileFormat(nil). - WithRawFileFormat(sdk.String("TYPE = JSON")), - ) + err := client.ExternalTables.Create(ctx, sdk.NewCreateExternalTableRequest(sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, name), stageLocation).WithRawFileFormat("TYPE = JSON")) require.NoError(t, err) externalTable, err := client.ExternalTables.ShowByID(ctx, externalTableID) @@ -94,15 +91,15 @@ func TestInt_ExternalTables(t *testing.T) { externalTableID, stageLocation, ). - WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeJSON)). - WithOrReplace(sdk.Bool(true)). + WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeJSON)). + WithOrReplace(true). WithColumns(columns). WithPartitionBy([]string{"filename"}). - WithRefreshOnCreate(sdk.Bool(false)). - WithAutoRefresh(sdk.Bool(false)). - WithPattern(sdk.String("weather-nyc/weather_2_3_0.json.gz")). - WithCopyGrants(sdk.Bool(true)). - WithComment(sdk.String("some_comment")). + WithRefreshOnCreate(false). + WithAutoRefresh(false). + WithPattern("weather-nyc/weather_2_3_0.json.gz"). + WithCopyGrants(true). + WithComment("some_comment"). WithTag([]*sdk.TagAssociationRequest{sdk.NewTagAssociationRequest(tag.ID(), "tag-value")}), ) require.NoError(t, err) @@ -128,9 +125,9 @@ func TestInt_ExternalTables(t *testing.T) { id, stageLocation, ). - WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithName(sdk.String(fileFormat.ID().FullyQualifiedName()))). + WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithName(fileFormat.ID().FullyQualifiedName())). WithQuery(query). - WithAutoRefresh(sdk.Bool(false))) + WithAutoRefresh(false)) require.NoError(t, err) _, err = client.ExternalTables.ShowByID(ctx, id) @@ -157,14 +154,14 @@ func TestInt_ExternalTables(t *testing.T) { externalTableID, stageLocation, ). - WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeParquet)). - WithOrReplace(sdk.Bool(true)). + WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeParquet)). + WithOrReplace(true). WithColumns(columnsWithPartition). WithPartitionBy([]string{"filename"}). - WithAutoRefresh(sdk.Bool(false)). - WithRefreshOnCreate(sdk.Bool(false)). - WithCopyGrants(sdk.Bool(true)). - WithComment(sdk.String("some_comment")). + WithAutoRefresh(false). + WithRefreshOnCreate(false). + WithCopyGrants(true). + WithComment("some_comment"). WithTag([]*sdk.TagAssociationRequest{sdk.NewTagAssociationRequest(tag.ID(), "tag-value")}), ) require.NoError(t, err) @@ -183,8 +180,8 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.Alter( ctx, sdk.NewAlterExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). - WithRefresh(sdk.NewRefreshExternalTableRequest("weather-nyc")), + WithIfExists(true). + WithRefresh(*sdk.NewRefreshExternalTableRequest("weather-nyc")), ) require.NoError(t, err) }) @@ -195,14 +192,14 @@ func TestInt_ExternalTables(t *testing.T) { err := client.ExternalTables.Create( ctx, minimalCreateExternalTableReq(name). - WithPattern(sdk.String("weather-nyc/weather_2_3_0.json.gz")), + WithPattern("weather-nyc/weather_2_3_0.json.gz"), ) require.NoError(t, err) err = client.ExternalTables.Alter( ctx, sdk.NewAlterExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). + WithIfExists(true). WithAddFiles([]*sdk.ExternalTableFileRequest{sdk.NewExternalTableFileRequest("weather-nyc/weather_0_0_0.json.gz")}), ) require.NoError(t, err) @@ -214,14 +211,14 @@ func TestInt_ExternalTables(t *testing.T) { err := client.ExternalTables.Create( ctx, minimalCreateExternalTableReq(name). - WithPattern(sdk.String("weather-nyc/weather_2_3_0.json.gz")), + WithPattern("weather-nyc/weather_2_3_0.json.gz"), ) require.NoError(t, err) err = client.ExternalTables.Alter( ctx, sdk.NewAlterExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). + WithIfExists(true). WithAddFiles([]*sdk.ExternalTableFileRequest{sdk.NewExternalTableFileRequest("weather-nyc/weather_0_0_0.json.gz")}), ) require.NoError(t, err) @@ -229,7 +226,7 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.Alter( ctx, sdk.NewAlterExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). + WithIfExists(true). WithRemoveFiles([]*sdk.ExternalTableFileRequest{sdk.NewExternalTableFileRequest("weather-nyc/weather_0_0_0.json.gz")}), ) require.NoError(t, err) @@ -244,8 +241,8 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.Alter( ctx, sdk.NewAlterExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). - WithAutoRefresh(sdk.Bool(true)), + WithIfExists(true). + WithAutoRefresh(true), ) require.NoError(t, err) }) @@ -304,7 +301,7 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.AlterPartitions( ctx, sdk.NewAlterExternalTablePartitionRequest(externalTableID). - WithIfExists(sdk.Bool(true)). + WithIfExists(true). WithAddPartitions([]*sdk.PartitionRequest{sdk.NewPartitionRequest("part_date", "2019-06-25")}). WithLocation("2019/06"), ) @@ -320,7 +317,7 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.AlterPartitions( ctx, sdk.NewAlterExternalTablePartitionRequest(externalTableID). - WithIfExists(sdk.Bool(true)). + WithIfExists(true). WithAddPartitions([]*sdk.PartitionRequest{sdk.NewPartitionRequest("part_date", "2019-06-25")}). WithLocation("2019/06"), ) @@ -329,8 +326,8 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.AlterPartitions( ctx, sdk.NewAlterExternalTablePartitionRequest(externalTableID). - WithIfExists(sdk.Bool(true)). - WithDropPartition(sdk.Bool(true)). + WithIfExists(true). + WithDropPartition(true). WithLocation("2019/06"), ) require.NoError(t, err) @@ -345,8 +342,8 @@ func TestInt_ExternalTables(t *testing.T) { err = client.ExternalTables.Drop( ctx, sdk.NewDropExternalTableRequest(externalTableID). - WithIfExists(sdk.Bool(true)). - WithDropOption(sdk.NewExternalTableDropOptionRequest().WithCascade(sdk.Bool(true))), + WithIfExists(true). + WithDropOption(*sdk.NewExternalTableDropOptionRequest().WithCascade(true)), ) require.NoError(t, err) @@ -363,11 +360,11 @@ func TestInt_ExternalTables(t *testing.T) { et, err := client.ExternalTables.Show( ctx, sdk.NewShowExternalTableRequest(). - WithTerse(sdk.Bool(true)). - WithLike(sdk.String(name)). - WithIn(sdk.NewShowExternalTableInRequest().WithDatabase(testDb(t).ID())). - WithStartsWith(sdk.String(name)). - WithLimitFrom(sdk.NewLimitFromRequest().WithRows(sdk.Int(1))), + WithTerse(true). + WithLike(name). + WithIn(*sdk.NewShowExternalTableInRequest().WithDatabase(testDb(t).ID())). + WithStartsWith(name). + WithLimitFrom(*sdk.NewLimitFromRequest().WithRows(sdk.Int(1))), ) require.NoError(t, err) assert.Equal(t, 1, len(et)) @@ -443,7 +440,7 @@ func TestInt_ExternalTablesShowByID(t *testing.T) { createExternalTableHandle := func(t *testing.T, id sdk.SchemaObjectIdentifier) { t.Helper() - request := sdk.NewCreateExternalTableRequest(id, stageLocation).WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeJSON)) + request := sdk.NewCreateExternalTableRequest(id, stageLocation).WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeJSON)) err := client.ExternalTables.Create(ctx, request) require.NoError(t, err) t.Cleanup(cleanupExternalTableHandle(t, id)) diff --git a/pkg/sdk/testint/streams_gen_integration_test.go b/pkg/sdk/testint/streams_gen_integration_test.go index f5e99fb7a2..ce6c4f96b6 100644 --- a/pkg/sdk/testint/streams_gen_integration_test.go +++ b/pkg/sdk/testint/streams_gen_integration_test.go @@ -59,7 +59,7 @@ func TestInt_Streams(t *testing.T) { t.Cleanup(stageCleanup) externalTableId := sdk.NewSchemaObjectIdentifier(db.Name, schema.Name, random.AlphanumericN(32)) - err := client.ExternalTables.Create(ctx, sdk.NewCreateExternalTableRequest(externalTableId, stageLocation).WithFileFormat(sdk.NewExternalTableFileFormatRequest().WithFileFormatType(&sdk.ExternalTableFileFormatTypeJSON))) + err := client.ExternalTables.Create(ctx, sdk.NewCreateExternalTableRequest(externalTableId, stageLocation).WithFileFormat(*sdk.NewExternalTableFileFormatRequest().WithFileFormatType(sdk.ExternalTableFileFormatTypeJSON))) require.NoError(t, err) t.Cleanup(func() { err := client.ExternalTables.Drop(ctx, sdk.NewDropExternalTableRequest(externalTableId))