Column renaming for the duration of a function call

Đang mở
#4,718 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
data

Hướng nghiên cứu

The issue describes a function-call feature using PRQL examples, but names no implementation files or tests. Start by reading the language’s function and relation handling to locate how function arguments are processed. Done means a function can use a caller-selected column for sorting without requiring the caller to add and remove a helper column explicitly.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

language-design

@snth has recently raised an issue that I remember we have already talked about, but cannot find now. I do think is a pain point and something we should do do better.

While on the topic of functions, one thing that I think is really needed is a way to alias columns in a relation passed to functions. I've thought a bit about this and I don't really know of an elegant way to do that.

Take for example a simple take_smallest function I use in my presentations:

let take_smallest = func n tbl -> (
  from tbl
  sort bytes
  take n
)

from tracks
group {album_id} (
  take_smallest 3
)

This works but bytes is hardcoded and you would really want that to be a parameter of take_smallest.

One workaround would be the following

let take_smallest = func n tbl -> (
  # Requires a _sort_by column to be set
  from tbl
  sort _sort_by
  take n
)

from tracks
group {album_id} (
  derive _sort_by=milliseconds
  take_smallest 3
  select !{_sort_by}
)

That works but you kinda want that derive _sort_by= ... select !{_sort_by} to happen implicitly inside the function definition.

Ngôn ngữ chính
Rust
Star
10.9k
Fork
261
Merge trung bình
3 ngày 21 giờ
Pull request đã merge (30 ngày)
84

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PRQL/prql

Tất cả issue của PRQL/prql

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.