Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define: add new columns to a specific position #56

Closed
xitology opened this issue Feb 15, 2024 · 3 comments
Closed

Define: add new columns to a specific position #56

xitology opened this issue Feb 15, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@xitology
Copy link
Member

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.

@clarkevans clarkevans added the enhancement New feature or request label Feb 26, 2024
@clarkevans
Copy link
Contributor

clarkevans commented Mar 28, 2024

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.

@xitology
Copy link
Member Author

xitology commented Mar 28, 2024

I'm thinking of the following interface:

  1. @funsql define(x => f()): if x already present, preserve its position, otherwise, add it to the end. This is the current behavior.
  2. @funsql define(x => f(), after = true): add or move x to the end.
  3. @funsql define(x => f(), after = y): add or move x to the next position after field y, an error if y does not exist.
  4. @funsql define(x => f(), before = true): add or move x to the beginning.
  5. @funsql define(x => f(), before = y): add or more x to the position right before y, an error if y does not exist.
  6. before and after cannot be both set.

@xitology
Copy link
Member Author

Added in 2459dd0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants