Skip to content

Commit 459fd37

Browse files
committed
Merge branch 'master' of github.com:starlake-ai/starlake
2 parents 5d6e217 + 0010e8f commit 459fd37

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ __Bug fix__:
2727
- JSON type ingestion in bigquery are now created with JSON type instead of String.
2828
- excluded table during data extraction defined in jdbcSchema are now taken into account
2929
- if column is renamed, check pattern of renamed column instead of original name since it is the target table column's name during schema extraction
30+
- restore time expiration for temporary tables
3031
- **BREAKING CHANGE** when no fields could be inferred from input, inferred schema now fails
3132

3233

src/main/scala/ai/starlake/job/ingest/loaders/BigQueryNativeLoader.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.google.cloud.bigquery
1717
import com.google.cloud.bigquery.{Field, JobInfo, StandardSQLTypeName, TableId}
1818
import com.typesafe.scalalogging.StrictLogging
1919

20+
import java.time.Duration
2021
import scala.jdk.CollectionConverters._
2122
import scala.util.{Failure, Success, Try}
2223

@@ -89,8 +90,8 @@ class BigQueryNativeLoader(ingestionJob: IngestionJob, accessToken: Option[Strin
8990
_.targetBqSchemaWithIgnoreAndScript(schemaHandler)
9091
)
9192

92-
val enrichedTableInfo = firstStepTableInfo.copy(maybeSchema =
93-
firstStepTableInfo.maybeSchema.map((schema: bigquery.Schema) =>
93+
val enrichedTableInfo = firstStepTableInfo.copy(
94+
maybeSchema = firstStepTableInfo.maybeSchema.map((schema: bigquery.Schema) =>
9495
bigquery.Schema.of(
9596
(schema.getFields.asScala :+
9697
Field
@@ -101,7 +102,8 @@ class BigQueryNativeLoader(ingestionJob: IngestionJob, accessToken: Option[Strin
101102
.setDefaultValueExpression(s"'$sourceUri'")
102103
.build()).asJava
103104
)
104-
)
105+
),
106+
maybeDurationMs = Some(Duration.ofHours(24).toMillis)
105107
)
106108

107109
// TODO What if type is changed by transform ? we need to use safe_cast to have the same behavior as in SPARK.

src/main/scala/ai/starlake/job/sink/bigquery/BigQueryJobBase.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,9 @@ trait BigQueryJobBase extends StrictLogging {
509509
.newBuilder(targetTableId, tableDefinition)
510510
.setDescription(tableInfo.maybeTableDescription.orNull)
511511

512-
if (tableInfo.maybePartition.isEmpty) {
513-
cliConfig.days match {
514-
case Some(days) =>
515-
bqTableInfoBuilder.setExpirationTime(
516-
System.currentTimeMillis() + days * 24 * 3600 * 1000
517-
)
518-
case None =>
519-
}
520-
}
512+
tableInfo.maybeDurationMs.foreach(d =>
513+
bqTableInfoBuilder.setExpirationTime(System.currentTimeMillis() + d)
514+
)
521515

522516
val bqTableInfo = bqTableInfoBuilder.build
523517
logger.info(s"Creating table ${targetTableId.getDataset}.${targetTableId.getTable}")

src/main/scala/ai/starlake/schema/model/TableInfo.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ case class TableInfo(
88
maybeSchema: Option[BQSchema] = None,
99
maybePartition: Option[FieldPartitionInfo] = None,
1010
maybeCluster: Option[ClusteringInfo] = None,
11-
attributes: List[AttributeDesc] = Nil
11+
attributes: List[AttributeDesc] = Nil,
12+
maybeDurationMs: Option[Long] = None
1213
)

0 commit comments

Comments
 (0)