Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Sep 30, 2024
1 parent dc3b123 commit be498a3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 279 deletions.
23 changes: 9 additions & 14 deletions warehouse/integrations/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ func (bq *BigQuery) DeleteTable(ctx context.Context, tableName string) (err erro
// only if the partition column exists in the schema.
// Otherwise, it creates a table with ingestion-time partitioning
func (bq *BigQuery) CreateTable(ctx context.Context, tableName string, columnMap model.TableSchema) error {
sampleSchema := getTableSchema(columnMap)
partitionColumn, partitionType := bq.partitionColumn(), bq.partitionType()

log := bq.logger.Withn(
logger.NewStringField(logfield.ProjectID, bq.projectID),
obskit.Namespace(bq.namespace),
logger.NewStringField(logfield.TableName, tableName),
logger.NewStringField("partitionColumn", partitionColumn),
logger.NewStringField("partitionType", partitionType),
)
log.Infon("Creating table")

sampleSchema := getTableSchema(columnMap)

partitionColumn := bq.partitionColumn()
partitionType := bq.partitionType()

var timePartitioning *bigquery.TimePartitioning
if partitionColumn == "" || partitionType == "" {
log.Infon("Creating table: Partition column or partition type not provided, using ingestion-time partitioning")
timePartitioning = &bigquery.TimePartitioning{
Type: bigquery.DayPartitioningType,
}
Expand All @@ -180,6 +180,7 @@ func (bq *BigQuery) CreateTable(ctx context.Context, tableName string, columnMap

// If partition column is _PARTITIONTIME and partition type is not empty, then we only set the partition type
if partitionColumn == "_PARTITIONTIME" {
log.Infon("Creating table: Partition column is _PARTITIONTIME")
timePartitioning = &bigquery.TimePartitioning{
Type: bqPartitionType,
}
Expand All @@ -190,19 +191,13 @@ func (bq *BigQuery) CreateTable(ctx context.Context, tableName string, columnMap
// 3. rudder_identity_mappings: we don't have any column.
_, ok := columnMap[partitionColumn]
if ok {
log.Infon("Creating table: Partition column found in schema",
logger.NewStringField("partitionColumn", partitionColumn),
logger.NewStringField("partitionType", partitionType),
)
log.Infon("Creating table: Partition column found in schema")
timePartitioning = &bigquery.TimePartitioning{
Field: partitionColumn,
Type: bqPartitionType,
}
} else {
log.Warnn("Creating table: Partition column not found in schema",
logger.NewStringField("partitionColumn", partitionColumn),
logger.NewStringField("partitionType", partitionType),
)
log.Infon("Creating table: Partition column not found in schema, using ingestion-time partitioning")
timePartitioning = &bigquery.TimePartitioning{
Type: bigquery.DayPartitioningType,
}
Expand Down
Loading

0 comments on commit be498a3

Please sign in to comment.