Skip to content

Commit

Permalink
Smoketest changes (#126)
Browse files Browse the repository at this point in the history
* Create static table CTEs as regular tables, instead of value tables.

* Convert UDF.Persistent to UDF.Temporary in smoketests.
  • Loading branch information
HenningKoller authored Jul 20, 2023
1 parent ee36066 commit 78cf13a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions testing/src/main/scala/no/nrk/bigquery/testing/BQSmokeTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ object BQSmokeTest {
ctesFromUDF ++ ctes.flatten
)
case pUdf @ UDF.Persistent(_, _, Body.Sql(body), _) =>
// todo: verify that this is what we want to do!
val (newUdfBody, ctesFromUDF) = recurse(body)
(
BQSqlFrag.Call(pUdf.copy(body = UDF.Body.Sql(newUdfBody)), newArgs),
BQSqlFrag.Call(
pUdf.copy(body = UDF.Body.Sql(newUdfBody)).convertToTemporary,
newArgs
),
ctesFromUDF ++ ctes.flatten
)
case _ => (BQSqlFrag.Call(udf, newArgs), ctes.flatten)
Expand Down Expand Up @@ -433,7 +435,7 @@ object BQSmokeTest {
val cteName = tempTable(pid)
(
cteName.bqShow,
List(CTE(cteName, bqfr"(select as value ${exampleRow(schema)})"))
List(CTE(cteName, bqfr"(select ${exampleRow(schema)})"))
)
case None =>
(p, Nil)
Expand All @@ -453,7 +455,7 @@ object BQSmokeTest {
List(
CTE(
cteName,
bqfr"(select as value ${exampleRow(fill.tableDef.schema)})"
bqfr"(select ${exampleRow(fill.tableDef.schema)})"
)
)
)
Expand Down Expand Up @@ -513,7 +515,9 @@ object BQSmokeTest {
.map(field => bqfr"${valueForType(field)} as ${Ident(field.name)}")
.mkFragment(bqfr"struct(", bqfr", ", bqfr")")

struct(schema.fields)
schema.fields
.map(field => bqfr"${valueForType(field)} as ${Ident(field.name)}")
.mkFragment(",")
}

// this is a user-wide query cache to speed up development/CI
Expand Down

0 comments on commit 78cf13a

Please sign in to comment.