Skip to content

Commit

Permalink
feat: Add helpers to BQField
Browse files Browse the repository at this point in the history
  • Loading branch information
hamnis committed Jun 15, 2023
1 parent 89f6b1c commit 7196a85
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/scala/no/nrk/bigquery/BQField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ case class BQField(
mode = if (mode == Field.Mode.REQUIRED) Field.Mode.NULLABLE else mode,
subFields = subFields.map(_.recursivelyNullable)
)

def withName(newName: String) = copy(name = newName)
def required = copy(mode = Field.Mode.REQUIRED)

def withType(newType: StandardSQLTypeName) = copy(tpe = newType)

def addSubFields(newSubFields: BQField*) =
withSubFields(subFields ::: newSubFields.toList)
def withSubFields(newSubFields: List[BQField]) =
if (tpe == StandardSQLTypeName.STRUCT) copy(subFields = newSubFields) else this

def addPolicyTags(newTags: String*) = copy(policyTags = policyTags ::: newTags.toList)
def withPolicyTags(newTags: List[String]) = copy(policyTags = newTags)
}

object BQField {
Expand Down

0 comments on commit 7196a85

Please sign in to comment.