Field name restrictions

#1

Can a type have a field name that starts with a number?
For example: “4thOfJuly”?

0 Likes

#2

Unfortunately no. See Can type names start with a digit?

0 Likes

Canonical field name restrictions and @schema overrides
#3

Just to be clear that doesn’t mean that you can’t map it to for example csv column that starts with a digit or has spaces. @schema(name) can be used for that

1 Like

#4

Which one is better to use for when the source file has columns that start with 0 or contain other special characters, Ann.Schema or Ann.Ser ?

@schema(fieldOverrides={'Z0Test': '0Test'})
type CanonicalMyTest mixes Source {
   Z0Test : string
}

vs

type CanonicalMyTest mixes Source {
    @ser(name="0Test")
    Z0Test : string
}

See:

0 Likes

#5

@karlbloedorn Well the @schema one won’t work as that’s not what it was intended for. That’s to be able to define an included type and have fields in different types that have that as a value type but the underlying physical table (hence “schema”) are different. This was intended/necessary to support external types with composite primary keys.

@garrynigel What would you recommend for what he is trying to do?

0 Likes

#6

@karlbloedorn @trothwein I would recommend @ser annotation because looks like while serializing the files you need to have certain fields to be serialized by other columns in the header.

0 Likes

#7

Thanks. I will try it out.

0 Likes