Open xitology opened 5 months ago
Databricks "ADD COLUMN" has two options:
FIRST If specified the column will be added as the first column of the table, or the field will be added as the first field of in the containing struct. AFTER identifier If specified the column or field will be added immediately after the field or column identifier.
I'm thinking of the following interface:
@funsql define(x => f())
: if x
already present, preserve its position, otherwise, add it to the end. This is the current behavior.@funsql define(x => f(), after = true)
: add or move x
to the end.@funsql define(x => f(), after = y)
: add or move x
to the next position after field y
, an error if y
does not exist.@funsql define(x => f(), before = true)
: add or move x
to the beginning.@funsql define(x => f(), before = y)
: add or more x
to the position right before y
, an error if y
does not exist.before
and after
cannot be both set.
Currently,
Define
adds any new columns at the end of the current column list. This is fine as the default behavior, but it should be possible to insert them at the beginning or at any particular position.Definitions that are replacing existing columns currently retain their positions. It should be possible to re-position them as if they are new columns.